We help IT Professionals succeed at work.

No value given for one or more required parameters.

Member_2_5230414
on
Medium Priority
340 Views
Last Modified: 2012-05-11
I get No value given for one or more required parameters. for

Public Class trackuser

    Public Shared Sub trackusers(ByVal thepage As String)
        Using con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Documents and Settings\perkinj\My Documents\Visual Studio 2010\WebSites\runningprofiles\forums\forum.mdb")
            Using cmd As New OleDbCommand("INSERT into nousersonline (`Username`,`Activity`,`PageUrl`,`ActivityDate`) VALUES (test1,test2," & thepage & ",test4)", con)
                con.Open()
                cmd.ExecuteNonQuery()
                con.Close()
            End Using
        End Using
    End Sub

End Class

Open in new window

Comment
Watch Question

Asim NazirProject Manager

Commented:
See if there is any primary key in the table and may be if that is not auto-generated then you need to pass that as well. Rest looks fine to me.

Author

Commented:
I have ActivityLogID and that is my primary and i have set this to autonumber (access)

Commented:
Using cmd As New OleDbCommand("INSERT into nousersonline (`Username`,`Activity`,`PageUrl`,`ActivityDate`) VALUES (test1,test2," & thepage & ",test4)", con)


Make sure you are pulling the values inserted , this usually means that values are not being pulled ,,,
Asim NazirProject Manager

Commented:
Ok. Then follow below links:

Here is helpful comment from the same links:
When using OLEDB with ADO.NET named parameters are unsupported. Instead, remove the parameter names from your SQL statement and replace each with a question mark. In addition, you can remove the parameter names when adding parameters to the Parameter collection. Just make certain to add them to the collection in the order which corresponds to their order in the SQL statement.

http://social.msdn.microsoft.com/forums/en-US/adodotnetdataproviders/thread/6e06fe86-b946-4803-973f-8604d335c776/
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Commented:
That might be also the problem ,

in that case use something like
InsertCommand="INSERT INTO [nousersonline](Username....) VALUES (?,?,?,?) "  >
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.