I have a table that I want to query based on a Selected Record in a gridView. I have the Record Number (that is the actual key field name) in GridView.SelectedValue but I have no idea how to set up a query in here much less run it. I need to know OldLine and oldItem from a table called items
I mean I know "Select OldItem, OldLine from Items where RecordNumber = " + GridValue.SelectedValue"
Sure hoped that worked but no... As you can probably tell I am relatively new to VB, VWD but not queries.
Please can someone give me an example of how to do this in a Public Sub
The whole purpose is to get the old item number so I can display an image in a particular query. I can do all but run the silly query and gather the data
Thanks in advance

Getting data from a query into variables
tizzdale27
hi,
i guess this link has answer for your question
http://msconline.maconstate.edu/tutorials/ASPNET2/ASPNET08/aspnet08-05.aspx
hope it will help
Rupesh Kumar
Here it is... Thanks for your help
Private Function GetConnectionString() As String Return "Data Source=US-NEW;Initial Catalog=Creations;Integrated Security=True" End Function Protected Sub ItemGridView_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Dim strConn As String = GetConnectionString() Dim sql As String = "Select OldLC, OldItem from Items Where RecordNumber = " & ItemGridView.SelectedValue.ToString() Dim strOldLC As String Dim strOldItem As String Using conn As New Data.SqlClient.SqlConnection(strConn) Dim objDR As Data.SqlClient.SqlDataReader Dim Cmd As New Data.SqlClient.SqlCommand(sql, conn)conn.Open()
objDR = Cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
strOldLC =
""strOldItem =
"" While objDR.Read()strOldLC = format(objDR(
"OldLC")strOldItem = (objDR(
"OldItem")) End WhilePage.DataBind()
TextBox1.Text = strOldLC & strOldItem
End UsingItemImage.ImageUrl =
"W:\wwwroot\smc\WebImagesConverted\images_small" & strOldLC & strOldItem & ".JPG" End SubLianne
hi,
my friend connections like that is some how old, microsoft in the asp.net 2.0 has a datasources to use it make it much easier than the past also you can do it with the same fasion
anyway i know its hard to learn it in microsoft help but you can take a look to this site its great i have learn alot from it
http://msconline.maconstate.edu/tutorials/ASPNET2/default.htm
you can find that under datasources
hope it was helpfull
shine
hi,
when you said vwd i thought its a web site, you also said you were able to retrieve the key value from the datagridview so
now i don't know if what you asked about was web form or windows form
also if you don't mind post part of your code that you have problem with
a9192shark
Well it helped. And it was nice to see that. I do already know how to change the Select Statement and rebind a table.
What I have is this. I have a table that has values that when combned will form a string that I can use to set the URL on an image
What I want is this
Get OldItem and OldLine onto a variable and add to an strng containing a path. This is then used to display the image.
When the user selects a record in the datagrid , I want to query this table to get those values using the SelectedValue (which is the key).
I have tried using a datasource as well as in,
stringVar = dataSource4.OldLine
Be nice if I could do that.
jessetechie
Yes it is a web form. I have a GridView that has Selection enabled when the user click on that, I want to run a query and get some values back and place them in a table...
There is no code. I really don;'t know where to begin.. my research says that I have to establish a connection, set the SQLCommand String and make a new Reader and execute that...
If I had any code I would post it. sorry.
I've done this in Oracle using a Fetch command.