如何使查询返回的类型为string啊
这个查询出来的结果不对,尤其是username项,他的值类型是string ,但是好象下面的查询返回的结果是int,我该如何更改下面的查询啊?麻烦各位大侠指点一下啊
Sub btnClick_Search(S As Object,E As EventArgs)
Dim username As String
Dim userid As String
username=txtSuser.Text
userid=txtSID.Text
conMyData=New SqlConnection("Server=Localhost;UID=sa;PWD=1;DataBase=Exam")
If txtSID.Text = "" and txtSuser.Text = "" Then
cmdSelect=New SqlCommand("Select userlist.*,dept.* from userlist,dept where dept.id=userlist.did order by userlist.id",conMyData)
End If
If txtSID.Text <> "" and txtSuser.Text = "" Then
cmdSelect=New SqlCommand("Select userlist.*,dept.* from userlist,dept where userlist.id=@id and dept.id=userlist.did order by userlist.id",conMyData)
End If
If txtSuser.Text <> "" and txtSID.Text = "" Then
cmdSelect=New SqlCommand("Select userlist.*,dept.* from userlist,dept where username=@name and dept.id=userlist.did order by userlist.id",conMyData)
End If
If txtSuser.Text <> "" and txtSID.Text <> "" Then
cmdSelect=New SqlCommand("Select userlist.*,dept.* from userlist,dept where username=@name and userlist.id=@id and dept.id=userlist.did order By userlist.id",conMyData)
End If
cmdSelect.Parameters.Add("@id",userid)
cmdSelect.Parameters.Add("@name",username)
conMyData.Open()
dgrdUser.DataSource=cmdSelect.ExecuteReader()
dgrdUser.DataBind()
conMyData.Close()
End Sub