tehon3299 Posted February 10, 2003 Posted February 10, 2003 Is this a valid SQL Statement?? "SELECT Last INTO txtLast.Text.ToString FROM tmUserInfo WHERE UserID = 'tehon3299'" UserID is in table tmUserInfo and Last is in the table also. If I put that query in the SQL Query Analyzer with out the INTO statement it works fine. I'm just not sure about that INTO statement. It must be wrong, because it is not working. Thanks Quote Thanks, Tehon
wayko Posted February 10, 2003 Posted February 10, 2003 the into command is used for inserting insert into table item value itemname Quote
Moderators Robby Posted February 10, 2003 Moderators Posted February 10, 2003 It looks like you want txtLast to display the value of Last for user 'tehon3299', am I correct? try this... Private Function GetTableValue(ByVal sUser As String) As String Dim drSqlReader As SqlDataReader Dim SqlCMD As SqlCommand Dim SqlCN As New SqlConnection(Conn)'Conn is your connection string Dim strSql As String, sTemp As String Try If SqlCN.State = ConnectionState.Closed Then SqlCN.Open() strSql = "SELECT Last FROM tmUserInfo WHERE UserID = '" & sUser & "'" SqlCMD = New SqlCommand(strSql, SqlCN) drSqlReader = SqlCMD.ExecuteReader() While drSqlReader.Read sTemp = CType(drSqlReader.Item("UserID"), String) End While Catch sTemp = "" Finally If Not SqlCN.State = ConnectionState.Closed Then SqlCN.Close() If Not drSqlReader.IsClosed Then drSqlReader.Close() If Not SqlCMD Is Nothing Then SqlCMD.Dispose() End Try Return sTemp End Function 'call the function like this... txtLast.Text = GetTableValue ("tehon3299") 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.