[求助]查询按钮代码错误
<P>在查询按钮下:<BR> strsql = "SELECT patID ,"<BR> strsql &= "patnam, "<BR> strsql &= "patnamkan,"<BR> strsql &= "patbirdat,"<BR> strsql &= "patsex, "<BR> strsql &= "numpatrelstu "<BR> strsql &= "From PatientLevel "<BR> <BR> <FONT color=#ee1111>If txtPatName.Text <> "" Then<BR> strsql &= "and patnam like '" & txtPatName.Text & "' "<BR> ElseIf txtPatID.Text <> "" Then<BR> strsql &= "and patID like '" & txtPatID.Text & "%' "<BR> ElseIf cboPatSex.Text <> "" Then<BR> strsql &= "and patsex = '" & cboPatSex.Text & "' "<BR> End If<BR></FONT> Try<BR> dt.Clear()<BR> cn.Open()<BR> da = New SqlDataAdapter(strsql, cn)<BR> da.Fill(dt)<BR> grdPatList.DataSource = dt<BR> btnModify.Enabled = True<BR> btnDel.Enabled = True<BR> If dt.Rows.Count = 0 Then</P><P> MsgBox("该查询结果不存在。")</P>
<P> End If</P>
<P> da.Dispose()<BR> Catch ex As Exception<BR> MsgBox(ex.Message)</P>
<P> Finally<BR> If cn.State = ConnectionState.Open Then<BR> cn.Close()</P>
<P> End If<BR> End Try</P> 你有什么问题你说出来啊..<BR>不要发段代码出来..什么事也不管了.. <P>你知道這段代碼執行后,STRSQL是什么不?<BR>、 strsql = "SELECT patID ,"<BR> strsql &= "patnam, "<BR> strsql &= "patnamkan,"<BR> strsql &= "patbirdat,"<BR> strsql &= "patsex, "<BR> strsql &= "numpatrelstu "<BR> strsql &= "From PatientLevel "<BR> <BR> If txtPatName.Text <> "" Then<BR> strsql &= "and patnam like '" & txtPatName.Text & "' "<BR> ElseIf txtPatID.Text <> "" Then<BR> strsql &= "and patID like '" & txtPatID.Text & "%' "<BR> ElseIf cboPatSex.Text <> "" Then<BR> strsql &= "and patsex = '" & cboPatSex.Text & "' "<BR> End If<BR>寫出這樣的代碼,服了你!<BR>你用msgbox(strsql)輸出下!</P> 不好意思~~忘了写上定义STRSQL~~我是在全局变量里定义的~<BR><BR><BR> strsql &= "From PatientLevel "<br><FONT color=#ff0000>=======><br></FONT>strsql &= "From PatientLevel where 1=1 "<br>
[align=right][color=#000066][此贴子已经被作者于2007-11-19 11:04:15编辑过][/color][/align]
页:
[1]
