Re: Help needed with Parameters/SQL Query by Jared
Jared
Fri Sep 10 13:06:33 CDT 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" <PaulSmith@discussions.microsoft.com> wrote in message
news:09E3929F-3FD0-482B-8217-22839F10ECB3@microsoft.com...
> 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 Smith@discussions.microsoft.com> wrote in message
>> news:413A8D17-8444-4B82-A324-0DA9919FA063@microsoft.com...
>> > 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
>>
>>
>>