no nid
5 1322
6
7
8
9
no nid
6 66
8
1
i want to add item to msaccess :eek2: :eek2: like this.
here the no field contains listitem.
i want codings in vb6
Printable View
no nid
5 1322
6
7
8
9
no nid
6 66
8
1
i want to add item to msaccess :eek2: :eek2: like this.
here the no field contains listitem.
i want codings in vb6
Try thisCode:'add a reference to the Microsoft ActiveX Data Object Library
Private Sub Command1_Click
Dim ADOCn As ADODB.Connection
Dim ConnString As String
Dim sSQL As String
Dim i As Long
ConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\yourdatabase.mdb;" & _
"Persist Security Info=False"
Set ADOCn = New ADODB.Connection
ADOCn.ConnectionString = ConnString
ADOCn.Open ConnString
For i = 0 To List1.ListCount - 1
sSQL = "INSERT INTO yourtablename (fieldname) "
sSQL = sSQL & "VALUES('" List1.List(i) & "' ")
ADOCn.Execute sSQL
Next
ADOCn.Close
Set ADOCn = Nothing
End Sub
thanks for ur reply.
i try this codings
error appear in this line
sSQL = sSQL & "VALUES('" List1.List(i) & "' ")
ADOCn.Execute sSQL
And what would that error be?
syntax error in
sSQL = sSQL & "VALUES(' " List1.List(i) & " ' ")
---------------
witht hanks
amala
Try thisCode:sSQL = sSQL & "VALUES('" & List1.List(i) & "' "
i try this code
error
------
syntax error "insert into statement"
ADOCn.Execute sSQL //-error
----------
Do thisAfter you run it, open the Immediate window and copy 'n paste what is there.Code:For i = 0 To List1.ListCount - 1
sSQL = "INSERT INTO yourtablename (fieldname) "
sSQL = sSQL & "VALUES('" & List1.List(i) & "' "
Debug.Print sSQL '<========= add this line
' ADOCn.Execute sSQL
Next