Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert INTO problem 2

Status
Not open for further replies.

newprogrammer999

Programmer
Aug 28, 2002
26
IE
Hi everyone,
I'm wondering if anyone can help me with this problem i have when I try to insert values in to an Access table from VB. Here is the relevant code:

Dim businessname As String
Dim firstname As String

businessname = txtBusinessName.Text
firstname = txtFirstName.Text

Dim sql As String
Dim oConn As New ADODB.Connection

oConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=H:\project\April08\Customerdb.mdb;Persist Security Info=False"
oConn.Open

sql = "INSERT INTO tblCustomer(ClientBusinessName, FirstName) VALUES (businessname, firstname)"
oConn.Execute (sql)


When I try to do this I get an error saying
"No value given for one or more required parameters" and the insert does not work. I have tried numerous solutions to this simple problem but just can't seem to find the answer. Any help would be greatly appreciated.

benny
 
The values you're passing aren't the contents of the variables:

sql = "INSERT INTO tblCustomer(ClientBusinessName, FirstName) VALUES ('" & businessname & "','" & firstname & "')"

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top