PC Review


Reply
Thread Tools Rate Thread

Help needed with Parameters/SQL Query

 
 
=?Utf-8?B?UGF1bCBTbWl0aA==?=
Guest
Posts: n/a
 
      10th Sep 2004
Hi I am new to this game.

I am trying to compile an applicaiton with an sql database.

I have a form and have linked to a certain table and the correct fields
display the correct values.

I have then added a combo box onto the form, would like to click a certain
persons name, and then it would display there information on the form. I
have followed some of microsoft walkthrough's - but after puttng in a try
catch - the error is saying:

Prepared statement '"@user_nameparam nvarchar(255)) SELECT employeeID,
User_Name, log' expects parameter @user_nameparam, which was not supplied

Any help greatly appreciated
 
Reply With Quote
 
 
 
 
Jared
Guest
Posts: n/a
 
      10th Sep 2004
If you Import the System.Data.SqlClient namespace you won't have to fully
qualify the types the way I did. Hope it helps.
Jared

Dim conn As New
System.Data.SqlClient.SqlConnection("Server=YourServerName;Database=YourDBName;Trusted_Connection=True;")
Dim cmd As New System.Data.SqlClient.SqlCommand("SELECT * FROM Customers
WHERE CustomerID=@CustomerID", conn)
cmd.Parameters.Add("@CustomerID", SqlDbType.VarChar)
cmd.Parameters("@CustomerID").Value = "Some_Value_You_Set"
Try
conn.Open()
Dim Reader As System.Data.SqlClient.SqlDataReader = cmd.ExecuteReader
'Do something with the reader here.
Catch sqlex As SqlClient.SqlException
'code to process sql errors
Catch ex As Exception
'code to process other errors
Finally
conn.Close()
End Try

"Paul Smith" <Paul (E-Mail Removed)> wrote in message
news:413A8D17-8444-4B82-A324-(E-Mail Removed)...
> Hi I am new to this game.
>
> I am trying to compile an applicaiton with an sql database.
>
> I have a form and have linked to a certain table and the correct fields
> display the correct values.
>
> I have then added a combo box onto the form, would like to click a certain
> persons name, and then it would display there information on the form. I
> have followed some of microsoft walkthrough's - but after puttng in a try
> catch - the error is saying:
>
> Prepared statement '"@user_nameparam nvarchar(255)) SELECT employeeID,
> User_Name, log' expects parameter @user_nameparam, which was not supplied
>
> Any help greatly appreciated



 
Reply With Quote
 
=?Utf-8?B?UGF1bCBTbWl0aA==?=
Guest
Posts: n/a
 
      10th Sep 2004
Jared, thanks for the help.

Still get the same error message.

"Jared" wrote:

> If you Import the System.Data.SqlClient namespace you won't have to fully
> qualify the types the way I did. Hope it helps.
> Jared
>
> Dim conn As New
> System.Data.SqlClient.SqlConnection("Server=YourServerName;Database=YourDBName;Trusted_Connection=True;")
> Dim cmd As New System.Data.SqlClient.SqlCommand("SELECT * FROM Customers
> WHERE CustomerID=@CustomerID", conn)
> cmd.Parameters.Add("@CustomerID", SqlDbType.VarChar)
> cmd.Parameters("@CustomerID").Value = "Some_Value_You_Set"
> Try
> conn.Open()
> Dim Reader As System.Data.SqlClient.SqlDataReader = cmd.ExecuteReader
> 'Do something with the reader here.
> Catch sqlex As SqlClient.SqlException
> 'code to process sql errors
> Catch ex As Exception
> 'code to process other errors
> Finally
> conn.Close()
> End Try
>
> "Paul Smith" <Paul (E-Mail Removed)> wrote in message
> news:413A8D17-8444-4B82-A324-(E-Mail Removed)...
> > Hi I am new to this game.
> >
> > I am trying to compile an applicaiton with an sql database.
> >
> > I have a form and have linked to a certain table and the correct fields
> > display the correct values.
> >
> > I have then added a combo box onto the form, would like to click a certain
> > persons name, and then it would display there information on the form. I
> > have followed some of microsoft walkthrough's - but after puttng in a try
> > catch - the error is saying:
> >
> > Prepared statement '"@user_nameparam nvarchar(255)) SELECT employeeID,
> > User_Name, log' expects parameter @user_nameparam, which was not supplied
> >
> > Any help greatly appreciated

>
>
>

 
Reply With Quote
 
Jared
Guest
Posts: n/a
 
      10th Sep 2004
Paul,
You would get more help if you posted the code block in question. It's
hard to troubleshoot a an exception when you have no code to accompany it.
Jared

"Paul Smith" <(E-Mail Removed)> wrote in message
news:09E3929F-3FD0-482B-8217-(E-Mail Removed)...
> Jared, thanks for the help.
>
> Still get the same error message.
>
> "Jared" wrote:
>
>> If you Import the System.Data.SqlClient namespace you won't have to fully
>> qualify the types the way I did. Hope it helps.
>> Jared
>>
>> Dim conn As New
>> System.Data.SqlClient.SqlConnection("Server=YourServerName;Database=YourDBName;Trusted_Connection=True;")
>> Dim cmd As New System.Data.SqlClient.SqlCommand("SELECT * FROM Customers
>> WHERE CustomerID=@CustomerID", conn)
>> cmd.Parameters.Add("@CustomerID", SqlDbType.VarChar)
>> cmd.Parameters("@CustomerID").Value = "Some_Value_You_Set"
>> Try
>> conn.Open()
>> Dim Reader As System.Data.SqlClient.SqlDataReader = cmd.ExecuteReader
>> 'Do something with the reader here.
>> Catch sqlex As SqlClient.SqlException
>> 'code to process sql errors
>> Catch ex As Exception
>> 'code to process other errors
>> Finally
>> conn.Close()
>> End Try
>>
>> "Paul Smith" <Paul (E-Mail Removed)> wrote in message
>> news:413A8D17-8444-4B82-A324-(E-Mail Removed)...
>> > Hi I am new to this game.
>> >
>> > I am trying to compile an applicaiton with an sql database.
>> >
>> > I have a form and have linked to a certain table and the correct fields
>> > display the correct values.
>> >
>> > I have then added a combo box onto the form, would like to click a
>> > certain
>> > persons name, and then it would display there information on the form.
>> > I
>> > have followed some of microsoft walkthrough's - but after puttng in a
>> > try
>> > catch - the error is saying:
>> >
>> > Prepared statement '"@user_nameparam nvarchar(255)) SELECT employeeID,
>> > User_Name, log' expects parameter @user_nameparam, which was not
>> > supplied
>> >
>> > Any help greatly appreciated

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to skip query parameters when not needed ? =?Utf-8?B?TS5BLkhhbGlt?= Microsoft Access 4 28th May 2009 05:06 PM
Set sub (embedded?) query parameters using VBA, call sub query in primary query with parameters completed Kelii Microsoft Access 4 5th Feb 2007 04:01 AM
Help Needed. Update with parameters error - No value given for one or more parameters. Hexman Microsoft VB .NET 2 10th Aug 2006 08:46 PM
Multiple parameters needed? =?Utf-8?B?TWlrZSBaaW1tZXI=?= Microsoft Access Reports 1 29th Jul 2005 03:38 AM
Help needed with Parameters =?Utf-8?B?Qm9nZ2ll?= Microsoft C# .NET 2 11th Aug 2004 01:21 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:44 PM.