mike_f1 Posted April 2, 2004 Posted April 2, 2004 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 Quote
eramgarden Posted April 2, 2004 Posted April 2, 2004 This is how I did it : 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 Quote
mike_f1 Posted April 4, 2004 Author Posted April 4, 2004 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? Quote
Moderators Robby Posted April 4, 2004 Moderators Posted April 4, 2004 Using eramgarden' s sample replace all Sql with OleDb for example: change this... Dim cmd As SqlCommand to this.... Dim cmd As OleDbCommand Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.