RE: Form questions
From: Suresh (anonymous_at_discussions.microsoft.com)
Date: 03/08/04
- Next message: bruce barker: "Re: Problem With the checkbox web control at framwork 1.1"
- Previous message: Curt_C [MVP]: "Re: What do you find difficult in ASP.net?"
- In reply to: Aaron: "RE: Form questions"
- Next in thread: Aaron: "RE: Form questions"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 8 Mar 2004 13:41:07 -0800
Your code looks ok to me.
You should be getting the following in the profiler when you trace the call.
sp_executesql N'select name_last, name_first from persons where name_last = @LastName', N'@LastName nvarchar(30)', @LastName = 'benage'
One more thing. Not sure if it'll help.
Set the following.
sqlCmd.CommandType = CommandType.Text
Suresh.
----- Aaron wrote: -----
My new code looks like this:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim sqlCmd As System.Data.SqlClient.SqlCommand = New
System.Data.SqlClient.SqlCommand("select name_last, name_first from
person where name_last = @LastName", SqlConnection1)
Dim SqlDataAdapter1 As System.Data.SqlClient.SqlDataAdapter = New
System.Data.SqlClient.SqlDataAdapter(sqlCmd)
sqlCmd.Parameters.Add(New System.Data.SqlClient.SqlParameter
("@LastName", SqlDbType.NVarChar, 30)) 'change type and length based on
your parameter
sqlCmd.Parameters("@LastName").Value = TextBox1.Text.Trim()
SqlDataAdapter1.Fill(DataSet11)
End Sub
When I run the code, I get the following in Profiler. I know that it is
hitting the server, but I don't think that the query is actually running
successfully. I am not using stored procedures.
sp_executesql N'select name_last, name_first from persons where name_last
= @LastName', N'@LastName nvarchar(30)', N'benage'
If I copy this into Query Analyzer I am prompted to define the variable.
Normally I would copy the query from profiler into QA to determine if the
syntax is correct and the resultant recordset is what I want. I can't do
that in this case.
I do not get any errors in IE.
Thanks for your help,
Aaron
=?Utf-8?B?U3VyZXNo?= <anonymous@discussions.microsoft.com> wrote in
news:68E87038-3706-407D-A49A-5FCA72638B95@microsoft.com:
> Dim SqlDataAdapter1 As SqlDataAdapter = New SqlDataAdapter(sqlCmd)
- Next message: bruce barker: "Re: Problem With the checkbox web control at framwork 1.1"
- Previous message: Curt_C [MVP]: "Re: What do you find difficult in ASP.net?"
- In reply to: Aaron: "RE: Form questions"
- Next in thread: Aaron: "RE: Form questions"
- Messages sorted by: [ date ] [ thread ]