Hi

Does any body know how to open a dll file. I can create a DLL file in VB6 but dont know how to reopen the code applied in it.

Have any one of you tried to use Single Quote () while doing database handling. Well if you try to save any string that contain a (), it will show a syntax error in your query. I had tried such a thing in ADODB Connectivity while working in VB 6.

Now the question arises,

What to do?

How to go further?

what is the solution?

The solution for the above problem is very simple. Use the function given below in your applcation & just pass your string through this function before assigning it to your SQL queryfor the ADODB Connection (or any other).

 

‘——————————————————————————

Public Function ReplaceToDb(ByVal strng As String)
    ReplaceToDb = Replace(strng, ““, ““)

 ’ Convert to

 ’ These are 2 Single Quotes, Not a Double Quote

‘ If i read it in words, it says

‘  ReplaceToDb Equalto Replace Bracket Open strng  Comma Double Qoute Single Qoute Double Qoute Comma Double Qoute Single Qoute Single Qoute Double Qoute Bracket Close 
End Function

‘——————————————————————————

.

..

….

Confused ?…….

look at the following example

Consider a synario of Change Password Module where you need to Change your current password

Change Password

Change Password

 

Dim dbCon as new ADODB.Connection

Public Function ReplaceToDb(ByVal strng As String)
        ReplaceToDb = Replace(strng, “‘”, “””)
End Function

Public Sub databaseConnect()
Dim dbSource As String
dbSource = App.Path & “\dummy.mdb”

    With dbCon
        .Provider = “Microsoft.Jet.OLEDB.4.0″
        .CursorLocation = adUseClient
        .Open dbSource
    End With

End Sub
Private Sub cmdOK_Click()
On Error GoTo ErrorLog
Dim recSet As New ADODB.Recordset
Dim strRecSet, UserID as String

    databaseConnect
    UserID = “Divyansh”
    strRecSet = “Select Pass from tblUsers Where UserID = ‘” & ReplaceToDb(UserID) & “‘;”
    recSet.CursorLocation = adUseClient
    recSet.Open strRecSet, dbCon, adOpenDynamic, adLockPessimistic

    If txtPass.Text = recSet!Pass Then
        If txtNewPass.Text <> “” Then
            If txtNewPass.Text = txtCPass.Text Then
                strRecSet = “Update tblUsers Set Pass = ‘” _
                            & ReplaceToDb(txtNewPass.Text) & “‘ Where UserID = ‘” & ReplaceToDb(UserID) & “‘;”
                dbCon.Execute (strRecSet)
                MsgBox “Password Changes Successfully”
                Unload Me
            Else
                MsgBox “Password Confirmation does not matches”
                txtNewPass.Text = “”
                txtCPass.Text = “”
                txtNewPass.SetFocus
            End If
        Else
            MsgBox “Password Cannot be left Blank”
            ClearText
            txtNewPass.SetFocus
        End If
    Else
        MsgBox “Please Check Your Password”
        ClearText
        txtPass.Text = “”
        txtPass.SetFocus
    End If
End Sub

Sub ClearText()
    txtNewPass.Text = “”
    txtCPass.Text = “”
End Sub

‘——————————————————————————-

where DbCon is the Connection & RecSet is a Recordset.

Hope this works.

Try it…………..