can not insert records in access database

  • Thread starter Thread starter Cedric Robinson via .NET 247
  • Start date Start date
C

Cedric Robinson via .NET 247

(Type your message here)

--------------------------------
From: Cedric Robinson
Hi, I am simply trying to insert records into an access database using asp.net. I can edit and update tables all day long. But when I go to insert I get this error.

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

Source Error:


Line 175: Me.OleDbConnection1.Open()
Line 176: Dim strSQL As String = "INSERT INTO Action_Items(Action_Item_No, Assigned_To) VALUES (txtActionItemNo.txt, txtAssignedTo.txt)"
Line 177: Me.OleDbInsertCommand1.ExecuteNonQuery()
Line 178: Me.OleDbConnection1.Close()
Line 179:

Here is my code. Can someone point me in the right direction. Thanks (I am new at this)

Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click

Dim myConnection As New OleDb.OleDbConnection()
Dim ex As Exception
' myConnection.Open()
Me.OleDbConnection1.Open()
Dim strSQL As String = "INSERT INTO Action_Items(Action_Item_No, Assigned_To) VALUES (txtActionItemNo.txt, txtAssignedTo.txt)"
Me.OleDbInsertCommand1.ExecuteNonQuery()
Me.OleDbConnection1.Close()

End Sub
 
Cedric Robinson via .NET 247 said:
(Type your message here)

Ok I will. You have a few things going on here...

I think what you're looking for is something like this:
Dim strSQL As String = "INSERT INTO Action_Items(Action_Item_No,
Assigned_To) VALUES ('" + txtActionItemNo.txt + "', '" + txtAssignedTo.txt
"')"

and you'll need to set the CommandText property before you execute the
command:
Me.OleDbInsertCommand1.CommandText = strSQL

and you'll need to set the Connection property (you may already be doing
this, I can't tell from the code you posted):
Me.OleDbInsertCommand1.Connection = Me.OleDbConnection1

If you'd like to use parameters instead (which I'd recommend, but right now
it might confuse you), check out the Parameters property.
http://msdn.microsoft.com/library/d...dataoledboledbcommandclassparameterstopic.asp


Wait a minute, where's the C# code? =P
asp.net. I can edit and update tables all day long. But when I go to insert
I get this error.
No value given for one or more required parameters.
Exception Details: System.Data.OleDb.OleDbException: No value given for
one or more required parameters.
Source Error:


Line 175: Me.OleDbConnection1.Open()
Line 176: Dim strSQL As String = "INSERT INTO
Action_Items(Action_Item_No, Assigned_To) VALUES (txtActionItemNo.txt,
txtAssignedTo.txt)"
Line 177: Me.OleDbInsertCommand1.ExecuteNonQuery()
Line 178: Me.OleDbConnection1.Close()
Line 179:

Here is my code. Can someone point me in the right direction. Thanks (I am new at this)

Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSubmit.Click
Dim myConnection As New OleDb.OleDbConnection()
Dim ex As Exception
' myConnection.Open()
Me.OleDbConnection1.Open()
Dim strSQL As String = "INSERT INTO Action_Items(Action_Item_No,
Assigned_To) VALUES (txtActionItemNo.txt, txtAssignedTo.txt)"
 

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

Back
Top