473,395 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Insert values into MS Access Database table

Hello Everyone

I want to insert values into MS Access database through VB.NET in Visual Studio 2005 . I have used the following code which is not working.

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim con As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLED B.4.0;Data Source=DSA.mdb")
con.Open()
Dim cmd As New OleDb.OleDbCommand("insert into users lname='" & TextBox2.Text & "' and lpwd='" & TextBox3.Text & "'" & "and Username='" & TextBox4.Text, con)

Please help me
May 3 '07 #1
6 7579
kenobewan
4,871 Expert 4TB
What error message are you receiving? Looks like you don't have your quotations right, suggest you debug. HTH.
May 3 '07 #2
What error message are you receiving? Looks like you don't have your quotations right, suggest you debug. HTH.
Thanks for the reply
The error I am facing is "syntax error in INSERT INTO statement"
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim con As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLED B.4.0;Data Source=DSA.mdb")
con.Open()
Dim cmd As New OleDb.OleDbCommand("insert into users lname='" & TextBox2.Text & "' and lpwd='" & TextBox3.Text & "'" & "and Username='" & TextBox4.Text, con)


Can U please provide the above statement with correct quotes.

I have even tried
Dim con As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLED B.4.0;Data Source=E:\Visual Studio 2005\Projects\image\WindowsApplication1\DSA.mdb")
con.Open()
Dim cmd As New OleDb.OleDbCommand("insert into users values '" & TextBox2.Text & "' '" & TextBox3.Text & "' '" & TextBox1.Text, con)
Dim dr As OleDb.OleDbDataReader = cmd.ExecuteReader(CommandBehavior.SingleResult)
May 12 '07 #3
Vijith
1
Dim cmd As New OleDb.OleDbCommand("insert into users(Field names seperated by comma) values( '" & TextBox2.Text & "' '" & TextBox3.Text & "' '" & TextBox1.Text & "' )", con)


You should complete the single quote for the last parameter.
Also specify field names of the table.
May 14 '07 #4
Hi Friends
I Am New To Vb.net Pls Help Me Out In For Connecting Msaccess And Sql Databases And Coding For It And Coding For Inserting,deleting,updating,next,previous First And Next Pls
Sep 22 '07 #5
how can we able to update ,insert,rows using asp.net.
I am new to dotnet pls help me out pls also specify for oracle and access
Sep 22 '07 #6
Dim cmd As New OleDb.OleDbCommand("insert into users(Field names seperated by comma) values( '" & TextBox2.Text & "' '" & TextBox3.Text & "' '" & TextBox1.Text & "' )", con)


You should complete the single quote for the last parameter.
Also specify field names of the table.
Thanks a lot for your response.
I am extremely thankful for your interest in solving my problem.
Nov 15 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: Philip Boonzaaier | last post by:
I want to be able to generate SQL statements that will go through a list of data, effectively row by row, enquire on the database if this exists in the selected table- If it exists, then the colums...
1
by: Christian Soltenborn | last post by:
Hi experts, I am working on a university project based on VB .NET. I have a connection to MS Access, and I want to insert some data into the database. The sql command INSERT INTO Shoe (Brand,...
6
by: efgh | last post by:
I'm fairly confident in my knowledge of SQL but I'm stumped with regards with an Insert Into statement in Access 2003. I've got a 4 column table that I've simplified about as much as I can, no...
1
by: Abareblue | last post by:
I have no clue on how to insert a record into access. here is the whole thing using System; using System.Drawing; using System.Collections; using System.ComponentModel;
4
by: authorking | last post by:
I use the following code to insert a data record in to a datatable of an access database.But every time I execute the command, there will rise an exception and the insert operation can't be...
1
by: geodev | last post by:
I’m copying data across from an Access database to an MSDE database through the use of some vb.net code. Unfortunately the application crashes when it goes to copy across data, in particular...
6
by: Marcel Hug | last post by:
Hi all ! I have a table in my database, which has 3 attributes. IDFailureControl, ControlDate and ControlVersion. In the following function I test, if the date of today allready exists. Then I...
7
by: Kevin Lawrence | last post by:
Hi all I want to do "INSERT INTO Table (Blob) Values('blobdataasstring')". ...rather than using the parameter driven method, is it possible? And if so what encoder do I use to convert the...
6
by: rn5a | last post by:
During registration, users are supposed to enter the following details: First Name, Last Name, EMail, UserName, Password, Confirm Password, Address, City, State, Country, Zip & Phone Number. I am...
2
by: paulmitchell507 | last post by:
I think I am attempting a simple procedure but I just can't figure out the correct syntax. My asp (classic) page runs a SELECT query to obtain dates and ID's from 2 tables uSQL = "SELECT...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.