Click here to Skip to main content
15,897,704 members

Comments by Member 14570812 (Top 2 by date)

Member 14570812 28-Aug-19 6:43am View    
is that correct there is an error in the line(Set .ActiveConnection = ocon")
Member 14570812 28-Aug-19 6:41am View    
Dim ocon As New ADODB.Connection
Dim ocom As ADODB.Command
Dim sql As String
Private Sub command1_click()
sql = "insert into krish(pid,name,class) values ("
sql = sql & "'" & Text1.Text & "',"
sql = sql & "'" & Text2.Text & "',"
sql = sql & "'" & Text3.Text & "')"
Set ocom = New ADODB.Command
With ocom
Set .ActiveConnection = ocon
.CommandText = sql
.Execute
End With
End Sub

Private Sub Form1_Load()
Set ocon = New ADODB.Connection
sCon = "Provider=SQLOLEDB.1;Server=BMSCW_CSNL_22;Database=krishna;Trusted_Connection=yes;"
With ocon
.ConnectionString = sCon
.Open
End With
End Sub
Private Sub form1_unload(cancel As Integer)
ocon.Close
End Sub