Getting info from database without using a datagrid - help!

mike_f1

Newcomer
Joined
Apr 2, 2004
Messages
2
I'm using request.querystring to get a value passed from a previous page. The value in question is a photoID number. From this I want to be able to get the phototname from the same table in the database. I've writtenthe query ("select photoname from photos where photoid = " & photoid & "") but I'm stuck when it comes to getting the photoname into a string variable. How do I do it?

I don't want to use a datagrid as the user doesn't need to know what's going on.

Hope I've explained it well enough and you lot can help me!

Thanks,
Mike
 
This is how I did it :

Code:
 Dim cnn As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnString"))
            Dim cmd As SqlCommand = cnn.CreateCommand

 cmd.CommandType = CommandType.Text

            cmd.CommandText = "SELECT  user_first, user_last, password,user_id  FROM user_m WHERE user_id = " & "'" & Replace(Trim(txtUserID.Text), "'", "''") & "'"
            cnn.Open()
            Dim dr As SqlDataReader = cmd.ExecuteReader

            If dr.Read() Then
                strFullName = dr.GetString(0) & " " & dr.GetString(1)
                strPassword = dr.GetString(2)
                strUserID = dr.GetString(3)
      end if
 
Thanks for your advice but I'm using MS Access and not mySQL.
Being a novice in ASP.NET, I'm led to believe this won't work as I can't use ".. new sql connection" and use oledbconnection and the MS Jet engine to connect.

Any ideas how it can be done using this set up?
 
Back
Top