By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,567 Members | 1,056 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,567 IT Pros & Developers. It's quick & easy.

can not insert records in access database

P: n/a
(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

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>GfMZAFnTuEKmRfi2lfY+rQ==</Id>
Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Cedric Robinson via .NET 247" <an*******@dotnet247.com> wrote in message
news:eQ****************@TK2MSFTNGP10.phx.gbl...
(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/de...eterstopic.asp
Wait a minute, where's the C# code? =P

--------------------------------
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

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>GfMZAFnTuEKmRfi2lfY+rQ==</Id>

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.