473,385 Members | 1,877 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,385 software developers and data experts.

Adding item in Database

3
Hi there. I have a simple Access database with names and numbers.
I'm trying to add another entry through vb6 but i get a SYNTAX ERROR in INSERT INTO statement.

Please help. What am i doing wrong?




Private Sub cmdAdd_Click()
Dim sql, nam, num As String

nam = InputBox("Enter Name:", "Name")
num = InputBox("Enter Number:", "Number")


sql = "INSERT INTO Contacts (Name, Number) VALUES " & nam & ", " & num

Call con.Execute(sql)

End Sub


Email
Aug 1 '06 #1
3 1798
Hemant Pathak
92 Expert
Hi Boby Please use this Code............
Private Sub cmdAdd_Click()
Dim sql, nam, num As String

nam = InputBox("Enter Name:", "Name")
num = InputBox("Enter Number:", "Number")


sql = "INSERT INTO Contacts (Name, Number) VALUES('" & nam & "','" & num & "')"

Call con.Execute(sql)

End Sub
Aug 1 '06 #2
bobby
3
I have tried using the code above, still the same syntax error appears.
What else can I check?
Aug 2 '06 #3
bobby
3
I just found that Name and Number or one of those were pre-defined names in Access causing my problem.
Thanks for the help.
Aug 2 '06 #4

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

Similar topics

3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
3
by: Robin Thomas | last post by:
I am fairly new to ASP.NET so I think I am missing something fundamental. Anyway, quite often I am pulling data from a database, but then I need to use that data to produce more data. A simple...
3
by: Chris Leuty | last post by:
I have a datagrid (with viewstate enabled), and my edit/update/delete buttons in the grid are all working fine. I have a textbox and a button underneath the grid for adding items to the grid. ...
2
by: Bob Hollness | last post by:
Hi group. I am a newbie to ASP.NET as you will see from some of the questions I may ask! I have a datagrid which I have populated from a database. It works great! I have added a column, via...
20
by: Bryan | last post by:
hello all... im trying to add a record to an sql db on ms sql server 2000, using vb.net. seems to be working.. except for one thing, one of the columns in the database is a bit datatype, and...
12
by: Art | last post by:
Hi everyone I was hoping someone might be able to help me with this. I'm just starting to try to work with MS Access tables through VB.net. In Access I can take an existing table and add a new...
4
by: pmcguire | last post by:
I have a treeview with a lot of nodes. I want to load only the nodes that are initially visible when the form loads, and then continue to populate it in background and/or when the nodes are required...
20
by: Ash Phillips | last post by:
Hi Everyone, I have this program I wrote in VB6 for family use. It's a DVD Database just for me to keep track of them cause I have so many lol. In VB6, I could add items to the ListView in...
6
by: Rudy | last post by:
Hi all, I know this is easy, just can't seem to get it. I have a windows form, and a text box, with a value already in it. I need to add that value to a table. It's just one value, so the entire...
5
by: Neo Geshel | last post by:
Greetings. I am in a very big pickle. I am trying to add page content - as well as a submit button - programatically to a web form that is supposed to submit to DB and then refresh. That...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.