Solved

help with vb.net and ms access database

Posted on 2007-04-01
3
189 Views
Last Modified: 2010-04-23
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
0
Comment
Question by:heydude
  • 2
3 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 250 total points
ID: 18833966
Try this:

str = "insert into table1 (sid, lname, fname) values('" & sid & "','" &  lname  & "','" & fname & "')"
0
 

Author Comment

by:heydude
ID: 18834071
Thank you for you help, that was all I needed.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 18834073
Glad to help :-)
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question