Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am trying to send and retrieve data from an MS Access Database I have created through VB6. I am using the following code which should send the data to my database where 'Players' is my table when I click on the submit button. It is however not working and I am getting an error saying 'User-defined type not defined' and the first line is highlighted. Any ideas? Please!
Dim cn As ADODB.Connection
Dim myRecordSet As ADODB.Recordset
Dim strsql As String
Set cn = New ADODB.Connection
cn.ConnectionString = Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\My Documents\Visual Work\db1.mdb;Persist Security Info=False
cn.Open
strsql = "INSERT INTO Players(field2,field3) VALUES('" & Text1 & "', '" & Text2 & "');"
Set myRecordSet = New ADODB.Recordset
myRecordSet.Open strsql, cn
Set myRecordSet = Nothing

you need to add the Microsoft Active X Database resource to your project.
Click on Project/Resources and then press 'M' until you see these listed.
Click on 2.5 or higher and then click OK.
Chi
They mostly come at night...mostly

Thanks with the new refernce it seems to work to some extent, no syntax errors now just runtime.
With the code above; I am getting the response 'Syntax error in INSERT INTO STATEMENT' when i click debug it highlights the line of code: myRecordSet.Open strsql, cn
This is very interesting as later on in my project on a different form when trying to read from the same database but a different table. I get the error message 'Data type mismatch in criteria expression' when I debug this error it points me again to the same line of code that it does have above.
This is really frustrating me as all that is wrong with my project is the database and the vb forms not interacting properly. It must be something simple surely that as a novice im just missing!? Please help, much appreciated. Jon

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |