Displaying results in text box from a hyperlink coulm in datagrid

N

Nithin

HI,
I have a datagrid that displays records. I have a hyperlink column
with a link to another page called "reportcal_details.aspx". Users can
go to the details page where they see all their information in text
box fields and update information.

My datagrid and hyperlink column works fine and I am able to send the
value of the "Ticket_id" (primary key) to the next page with the query
string in the URL
http://localhost/myprojects/tasktra...icket_id=20001.

I am even able to print this Ticket_id on my reportcal_details.aspx
page. But, I am unable to display the values for that Ticket_id inside
a text box that the users can update.

Here is the code for the details page. I have included just one text
box to make it easier.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim _reader As SqlDataReader
Dim strTicketId As String = Request.QueryString("Ticket_id")
Response.Write("The Ticket ID is " + strTicketId + "<br>")

Dim strSQL2 As String = "SELECT Bsc" & _
"FROM Tracker2" & _
"WHERE Ticket_id= '" & strTicketId & "'"
Dim objCmd As New SqlCommand(strSQL2, MyConnection)

Try
MyConnection.Open()
_reader = objCmd.ExecuteReader()
If _reader.Read Then
txtBsc.Text = "Bsc"
End If
_reader.Close()
Catch ex As SqlException
Response.Write(ex.ToString)
MyConnection.Close()

End Try
End Sub

Here is how my ERROR page appears:

The Ticket ID is 20001

System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near
'Ticket_id'. at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream) at
System.Data.SqlClient.SqlCommand.ExecuteReader() at
tasktracker.reportcal4_details.Page_Load(Object sender, EventArgs e)
in C:\Inetpub\wwwroot\myprojects\tasktracker\reportca
l4_details.aspx.vb:line 41
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top