adding to ms access database using VB 2008

gloringg

Member
Joined
Jan 11, 2009
Messages
16
Programming Experience
Beginner
Can some one help me with the following.

I have two tables in the MS Access 2003 database " SAMPLE" and they are : 1. INFO 2. INFO2

Now i have created a form in VB 2008 express edition with the text boxes: Name, Age, Occupation.

The tables INFO has - Name, Age as columns
And INFO 2 has - Name, Age, Occupation.

All i want is when the user presses the ok button, it should add the name & age to INFO and also add Name, Age Occupation to the INFO 2 Table.


Can some one please help me with the sample code....

I am succesful in connecting the database.
thanks
 
VB.NET:
dim cmd as oledcommand=new oledbcommand("querystring","connectionstring")
cmd.executeNonquery
connection.close
u can use two executenonquery to update two tables.
 
Last edited:
Thank you

Hi,

Thanks for your reply,

Just few Q here.

when you say query string i need to use insert (SQL Command),right?
when i have a blan in between then is it gonna work.

Example

Table 1

Name | Age | Location

Table 2

Name | Location | Age

can you please give me a sample query for updating this tables with the name age and location data.


Thank you So much for the help.
 
"insert into table1 values('" & textbox1.text & "','" & textbox2.text & "','" & textbox3.text & "')
use two oledbCommand.

No no no no no!

Never ever write an SQL like that again, and certainly never tell a newbie to write them like that. (Read the PQ link in my signature)

gloringg: Read the DW2 link in my signature, there you will find how to get the Visual Studio designer to help you interact with your database. What you ask is so trivially easy I could do it in about 1 minute using the designer, and the code will be faster and more reliable than what it would take all day to write manually.

Read the DW2 link, starting with the Creating a Simple Data App section
 
Back
Top