1,105,214 Community Members

Visual Studio 2010 + Web Form + Insert + Access Database

Member Avatar
System Jay
Newbie Poster
7 posts since Apr 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I cannot believe how loooooong i have been searching the internet for this. However i have a form that i have created in Visual studio 2010.

I have 3 text boxes for FIRST NAME, LAST NAME and NOTES. I have 1 button to submit data.

When i click the button to submit the data, i would like for the data to insert into the database.

I can deal with validation, viewing the data and making it fancy later. For now, i just need the code behind the button to insert it into an Access 2010 database.

Please any help for a newbie.

Thank you in advance

System Jay

Member Avatar
Reverend Jim
Noli mentula
5,394 posts since Aug 2010
Reputation Points: 746 [?]
Q&As Helped to Solve: 643 [?]
Skill Endorsements: 51 [?]
Moderator
Featured
 
0
 

The actual syntax of the SQL query is
INSERT INTO table (col1name,col2name,...) VALUES(val1,val2,...)

An actual example would be

insert into mytable (first_name,last_name,notes) values("john","smith","heck of a nice guy");

with table named "mytable". An example in VB would be

firstname = "John"
lastname = "Smith"
notes = "a heck of a nice guy"
table = "mytable"

query = "insert into " & table & " (first_name,last_name,notes) values(""" & firstname & """,""" & lastname & """,""" & notes & """)"

if your connection object is named "con" then execute the query by

con.Execute(query)

I find that the hardest part is keeping all the extra double quotes straight.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: