Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding item from listbox to database.

Status
Not open for further replies.

Danielgraham

Programmer
Jun 8, 2004
21
GB
Hello.
im useing VB6 with a listbox. and on a button click i would like to insert that data to a table in a microsoft access database.

Please help
Thankyou

Daniel

 
look at using ADO, together with the SQL INSERT statement, looping over the items of the listbox.

All of these can be found by searching these Forums and FAQ's (
Search them, and then post some of your code if you still have problems.




Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
I Dont know where im going wrong

admin.data.Open
admin.data.Execute "insert into data (test) values (Dan)"
admin.data.Close


Dan
 
Please post full code. what you have here does not tell us what admin or data is.

Make sure you have referenced the correct ADO components.

and give us the error you are getting with the above code.

just one of many.
look at thread222-681063 for some insert sql examples

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Ok changed the way of doing this and it still has the same error.


Private Sub Command1_Click()
Dim mycon As New ADODB.Connection


Set mycon = New ADODB.Connection
mycon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\station.mdb;Persist Security Info=False"
mycon.Open

mycon.Execute "INSERT INTO station (Text1) VALUES (Test)"
mycon.Close

End Sub



Error: No Value given for one or more required parameters.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top