Link to home
Start Free TrialLog in
Avatar of heydude
heydude

asked on

help with vb.net and ms access database

I have a serious brain block going on and I think I have turned this piece of code into one big disaster, I have a couple of variables that I want to insert into an ms access table and I am at a mind block. Below is my code. May be totally wrong, partly correct, not sure. All variables are strings.

Try
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\emp.mdb;")
cn.Open()
str = "insert into table1 (sid, lname, fname) values(" & ("sid") & ",'" & ("lname") & "','" & ("fname") & "')"
cmd = New OleDbCommand(str, cn)
Cmd.CommandText = str
Cmd.ExecuteNonQuery()

Catch
End Try
cn.Close()

Thank you
ASKER CERTIFIED SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of heydude
heydude

ASKER

Thank you for you help, that was all I needed.
Glad to help :-)