Last post Apr 15, 2011 10:35 PM by Decker Dong - MSFT
Apr 13, 2011 12:32 PM|chrisyc|LINK
Hi, I've created a SQL data adaptor which returns results to A textbox. There where function is to pull the data from a label Within the page e.g. Select from table1 where Id = @customerid. The customer Id is generated on page load and is output to a hidden
label. However I'm currently struggling to get the parameter to Work. It doesn't seem to be connecting to the label. Any help Would be appreciated . Thanks
Code Example Below
<script Language="VB" Option="Explicit" runat="server">
Protected Sub Page_Load1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim SQLData As New System.Data.SqlClient.SqlConnection("Data Source=********************************************")
Dim cmdSelect As New System.Data.SqlClient.SqlCommand("SELECT authorfirstname FROM Author WHERE ([AuthorID] = @UserID)", SQLData)
' Add parameters and set values.
"UserID", SqlDbType.NVarChar, 36).Value = LblUserIDValue.Text
Dim dtrReader As System.Data.SqlClient.SqlDataReader = cmdSelect.ExecuteReader()
If dtrReader.HasRows Then
TextBox2.Text = dtrReader("authorfirstname")
Apr 13, 2011 04:57 PM|slanka|LINK
1. Make sure that the page_load method is getting called.
2. Make sure that are no leading/trailing spaces in LblUserIDValue.Text
Apr 14, 2011 03:31 AM|chrisyc|LINK
Thanks for the reply.
I have checked the above 2 steps and confirm that they look ok, however this is still not working.
When 'Tracing' the database i can see the select query however the @UserID is showing as ''.
Is there anymore details you need ?
Apr 14, 2011 02:34 PM|slanka|LINK
How are you setting the text for LblUserIDValue?
Can you put Reponse.Write(LblUserIDValue.Text) at the beginning of page_load method and see it was set?
Apr 15, 2011 10:35 PM|Decker Dong - MSFT|LINK
You can try this:
' Add parameters and