关于if ...然后[解决]的错误 [英] an error about if ... then [Solved]
本文介绍了关于if ...然后[解决]的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么这段代码会在网上出错:如果Val(Label1.Text)= 1那么
公共 Sub get_data()
cn.Open()
Dim dt 作为 新 DataTable( shakhes)
Dim rs 作为 新 SqlDataAdapter( select *来自shakhes sal_tadieh ='& TextBoxX1.Text& '和mah_tadieh ='& ComboBox1.SelectedItem& ',cn)
rs。填充(dt)
ShakhesDataGridView.DataSource = dt
ShakhesDataGridView .Refresh()
Label1.Text = dt.Rows.Count
rs.Dispose()
cn.Close(
If Val(Label1.Text)= 1 然后
Dim i As Integer
i = ShakhesDataGridView.CurrentRow.Index
TextBoxX2.Text = ShakhesDataGridView.Item( 2 ,i).Value
End 如果
结束 Sub
解决方案
你错过了)你关闭连接的行
cn.Close(
更改为
cn.Close()
hi why this code make error on line : If Val(Label1.Text) = 1 Then
Public Sub get_data()
cn.Open()
Dim dt As New DataTable("shakhes")
Dim rs As New SqlDataAdapter("select * from shakhes where sal_tadieh='" & TextBoxX1.Text & "' and mah_tadieh='" & ComboBox1.SelectedItem & "'", cn)
rs.Fill(dt)
ShakhesDataGridView.DataSource = dt
ShakhesDataGridView.Refresh()
Label1.Text = dt.Rows.Count
rs.Dispose()
cn.Close(
If Val(Label1.Text) = 1 Then
Dim i As Integer
i = ShakhesDataGridView.CurrentRow.Index
TextBoxX2.Text = ShakhesDataGridView.Item(2, i).Value
End If
End Sub
解决方案
you have missed ) in line where you close the connection
cn.Close(
change to
cn.Close()
这篇关于关于if ...然后[解决]的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文