S
sbox
I've got an error "System.FormatException: Input string was not in a correct
format." while I'm implementing a datagrid and a textbox
What's wrong with it?
Sub Button1_Click(sender As Object, e As EventArgs)
DataGrid1.DataSource = MyQueryMethod(CInt(TextBox1.Text))
DataGrid1.DataBind()
End Sub
Function MyQueryMethod(ByVal others As String) As System.Data.DataSet
Dim connectionString As String = "server='localhost'; user id='******';
password='******'; database='******'"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.SqlClient.SqlConnection(connectionString)
Dim queryString As String = "SELECT [Software].* FROM [Software] WHERE
([Software].[Others] like @Others)"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_others As System.Data.IDataParameter = New
System.Data.SqlClient.SqlParameter
dbParam_others.ParameterName = "@Others" dbParam_others.Value = others
dbParam_others.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_others)
Dim dataAdapter As System.Data.IDbDataAdapter = New
System.Data.SqlClient.SqlDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)
Return dataSet
End Function
format." while I'm implementing a datagrid and a textbox
What's wrong with it?
Sub Button1_Click(sender As Object, e As EventArgs)
DataGrid1.DataSource = MyQueryMethod(CInt(TextBox1.Text))
DataGrid1.DataBind()
End Sub
Function MyQueryMethod(ByVal others As String) As System.Data.DataSet
Dim connectionString As String = "server='localhost'; user id='******';
password='******'; database='******'"
Dim dbConnection As System.Data.IDbConnection = New
System.Data.SqlClient.SqlConnection(connectionString)
Dim queryString As String = "SELECT [Software].* FROM [Software] WHERE
([Software].[Others] like @Others)"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_others As System.Data.IDataParameter = New
System.Data.SqlClient.SqlParameter
dbParam_others.ParameterName = "@Others" dbParam_others.Value = others
dbParam_others.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_others)
Dim dataAdapter As System.Data.IDbDataAdapter = New
System.Data.SqlClient.SqlDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)
Return dataSet
End Function