₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,034 members, 8,420,006 topics. Date: Thursday, 04 June 2026 at 09:20 AM

Toggle theme

Abhicool's Posts

Nairaland ForumAbhicool's ProfileAbhicool's Posts

1 (of 1 pages)

ProgrammingRe: Connecting To A Database Using Visual Basic by abhicool: 6:28pm On Mar 23, 2013
erm... saw the posts... i am a beginner at databases programming and am trying to make up a project using databases. i did it using adodc.. here is what steps i followed...
1.added an OLEDB component to my form named it as newcon, set its ConnectionString property as "Provider=Microsoft.Jet.OLEDB.4.0;userID=Admin;Data Source=" &App.Path & "\newdb.mdb; Persist security info=False"
2. set CommandType as 2-adCmdTable
3.set Record Source as emp1(here emp1 is the table with 3 fields namely ID, salary and empname)
4. took 3 textboxes with data source as newcon and attached each with an individual field of the table.
5.included a command button for submit.
6. typed the following code

Dim con As ADODB.Connection
Dim rs As ADODB.Recordset

Private Sub Command1_Click()
con.Open ("Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=" & App.Path & "\newdb.mdb;Persist Security info=False"wink
con.Execute ("insert into emp1 values('" + Text1.Text + "','" + Text2.Text + "','" + Text3.Text + "')"wink
rs.Close
con.Close
Set rs = Nothing
Set con = Nothing
End Sub

Private Sub Form_Load()
Set con = New ADODB.Connection
Set rs = New ADODB.Recordset
End Sub


on executing this i am persistantly getting "data type mismatch in criteria expression" as a runtime error..
what can be the problem?? please help its frustating...

1 (of 1 pages)