adding data...got problem....pls help

Z

zheetee

i am beginner to link asp.net and access 2gether
i use asp .net matrix...and wrote the Insert data coding

Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole
DB Services=-4; Data Source=C:\Documents an"& _
"d Settings\AliceLee\My Documents\db\equipment.mdb"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.OleDb.OleDbConnection(connectionString)

Dim queryString As String = "INSERT INTO [test]
([SerialNumber]) VALUES (SerialNumber1)"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim rowsAffected As Integer = 0
dbConnection.Open
Try
rowsAffected = dbCommand.ExecuteNonQuery
Finally
dbConnection.Close

End Try

'Return rowsAffected

it returned--> Exception Details: System.Data.OleDb.OleDbException: No
value given for one or more required parameters.

SerialNumber1 is a textbox that i using in the asp.net page....

can i know what is the problem???
why cant get the add the SerialNumber1.text into access???
 
G

Guest

If "SerialNumber1" is a textbox control, then its value should be

SerialNumber1.Text

Peter
 
J

Jeff Dillon

You need to concatenate your SerialNumber1.Text value into your string.

Practice on a program that doesn't connect to the database, and learn how to
build strings.

Dim queryString As String = "INSERT INTO [test] ([SerialNumber]) VALUES ('"
& SerialNumber1.Text & "')"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top