Datagrid and matching input with db problem.
In webform there is a datagrid tool. In datagrid, we can add the bound column, button column and hyperlink column. When i add button column(Edit, update, cancel button) in datagird. How i'm i suppose to do to make the button column works? As in when i click on the button column it will bring me to another page. I need help please!
I have a 2nd qns, i allow the user to key in the year and the year will match with the database then retreive the info and display in the datagrid.
I have this code******
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim key As String = TextBox1.Text
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & Server.MapPath("movie.mdb")
Dim strSQL As String = "SELECT Title, Year FROM movieDet WHERE Year = 'key' "
Dim cmd As New OleDbCommand(strSQL, New OleDbConnection(strConn))
cmd.Connection.Open()
DataGrid1.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection)
DataGrid1.DataBind()
cmd.Connection.Close()
cmd.Connection.Dispose()
End Sub
I try to run the program but it gave me an error "Data type mismatch in criteria expression. " in this line: "DataGrid1.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection)"
How can i solve it? Help please! its urgent. Thankx.
In webform there is a datagrid tool. In datagrid, we can add the bound column, button column and hyperlink column. When i add button column(Edit, update, cancel button) in datagird. How i'm i suppose to do to make the button column works? As in when i click on the button column it will bring me to another page. I need help please!
I have a 2nd qns, i allow the user to key in the year and the year will match with the database then retreive the info and display in the datagrid.
I have this code******
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim key As String = TextBox1.Text
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & Server.MapPath("movie.mdb")
Dim strSQL As String = "SELECT Title, Year FROM movieDet WHERE Year = 'key' "
Dim cmd As New OleDbCommand(strSQL, New OleDbConnection(strConn))
cmd.Connection.Open()
DataGrid1.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection)
DataGrid1.DataBind()
cmd.Connection.Close()
cmd.Connection.Dispose()
End Sub
I try to run the program but it gave me an error "Data type mismatch in criteria expression. " in this line: "DataGrid1.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection)"
How can i solve it? Help please! its urgent. Thankx.
Last edited: