Click here to Skip to main content
15,899,632 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
hi why this code make error on line : If Val(Label1.Text) = 1 Then
VB
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
Posted
Updated 15-Aug-15 16:43pm
v2
Comments
rezaeti 15-Aug-15 21:02pm    
please help !
AnvilRanger 15-Aug-15 21:11pm    
What error are you getting?
rezaeti 15-Aug-15 21:16pm    
an missing (
rezaeti 15-Aug-15 21:19pm    
thanks solved

1 solution

you have missed ) in line where you close the connection
VB
cn.Close(

change to
VB
cn.Close()
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900