When I click on search button, this code below will run. There are no errors on the code but datagridview shows only the column name.. Is there a mistake for the query?
mySqlConn = New MySqlConnection
myCommand = New MySqlCommand
dt = New DataTable()
Try
If dt IsNot Nothing Then
dt.Dispose()
End If
If da IsNot Nothing Then
da.Dispose()
End If
If DataGridView1.DataSource IsNot Nothing Then
DataGridView1.DataSource = Nothing
End If
mySqlConn.ConnectionString = connStr
myCommand.CommandText = "Select * from createproject Where (FloatNumber = @floatNo OR @floatNo is Null) AND (DeveloperName = @devName OR @devName is Null) AND (DevelopmentType = @devType OR @devType is Null) AND (LotPt = @lotPt OR @lotPt is Null) AND (Mukim = @mukim OR @mukim is Null) AND (Daerah = @daerah OR @daerah is Null) AND (Negeri = @negeri OR @negeri is Null) AND (TempReference = @tempRef OR @tempRef is Null)"
myCommand.Connection = mySqlConn
mySqlConn.Open()
myCommand.Parameters.AddWithValue("@floatNo", TextBox3.Text.Trim())
myCommand.Parameters.AddWithValue("@devName", ComboBox6.Text.Trim())
myCommand.Parameters.AddWithValue("@devType", ComboBox7.Text.Trim())
myCommand.Parameters.AddWithValue("@lotPt", TextBox4.Text.Trim())
myCommand.Parameters.AddWithValue("@mukim", ComboBox8.Text.Trim())
myCommand.Parameters.AddWithValue("@daerah", ComboBox9.Text.Trim())
myCommand.Parameters.AddWithValue("@negeri", ComboBox10.Text.Trim())
myCommand.Parameters.AddWithValue("@tempRef", TextBox6.Text.Trim())
da = New MySqlDataAdapter(myCommand.ToString(), mySqlConn)
da.SelectCommand = myCommand
da.Fill(dt)
DataGridView1.DataSource = dt
da.Update(dt)
Catch ex As MySqlException
MsgBox(ex.ToString())
Finally
mySqlConn.Close()
mySqlConn.Dispose()
End Try