Public adoConn As New ADODB.Connection
Public adoCmd As ADODB.Command
Public strConn As String
Public adoRst As ADODB.Recordset
Public Function ConnDB()
adoConn = New ADODB.Connection
strConn = "Data Source=localhost; Provider=SQLOLEDB.1;Initial Catalog=HRMS;Integrated Security=SSPI;"
With adoConn
.Mode = ADODB.ConnectModeEnum.adModeShareDenyNone
.CursorLocation = ADODB.CursorLocationEnum.adUseClient
.ConnectionString = strConn
''.show()
End With
' adoCmd = New ADODB.Command
'adoCmd.ActiveConnection = adoConn
'adoCmd.CommandType = adCmdText
End Function
My form1 save command code for testing connection is as below;
Private Sub cmdSave_Click()
''Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
Call ConnDB
adoConn.Execute ("Insert into dbo.testy (firstname,address,status,phone,location) values ('" & txtfname.Text & "','" & txtaddress.Text & "','" & cbostatus.Text & "','" & txtlocation.Text & "','" & txtphone.Text & "')")
MsgBox ("Details Saved")
'' End ConnDB()
'' frm1.Show()
End Sub
Please assist and advice between VB6 and vb2005 express which I should go for????
Edited by macosxnerd101: Please use code tags, like so:

New Topic/Question
Reply




MultiQuote



|