Soldato
www.saywhatagain.co.uk/images/queryproblem.JPG
The above is my page at the moment. I basically need to need have four queries on one page where the datagrid gives the result. The query is in place but I just can't figure out the code i need to tie the textboxes to the query :s
The code below is what i have so far
Can anyone help, i know i've got to put some code into the button sub,but i just can't figure out what!
The above is my page at the moment. I basically need to need have four queries on one page where the datagrid gives the result. The query is in place but I just can't figure out the code i need to tie the textboxes to the query :s
The code below is what i have so far
Function MyQueryMethod(ByVal format As String, ByVal price As Decimal, ByVal minimumAge As Integer, ByVal type As String) As System.Data.DataSet
Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=db\gamedb.mdb"
Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString)
Dim queryString As String = "SELECT [products].[GameID], [products].[Title], [products].[Format], [products].["& _
"Price], [products].[Type], [products].[Publisher], [products].[MinimumAge], [pro"& _
"ducts].[Quantity] FROM [products] WHERE (([products].[Format] = @Format) AND ([p"& _
"roducts].[Price] <= @Price) AND ([products].[MinimumAge] <= @MinimumAge) AND ([p"& _
"roducts].[Type] = @Type))"
Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_format As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
dbParam_format.ParameterName = "@Format"
dbParam_format.Value = format
dbParam_format.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_format)
Dim dbParam_price As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
dbParam_price.ParameterName = "@Price"
dbParam_price.Value = price
dbParam_price.DbType = System.Data.DbType.Currency
dbCommand.Parameters.Add(dbParam_price)
Dim dbParam_minimumAge As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
dbParam_minimumAge.ParameterName = "@MinimumAge"
dbParam_minimumAge.Value = minimumAge
dbParam_minimumAge.DbType = System.Data.DbType.Int32
dbCommand.Parameters.Add(dbParam_minimumAge)
Dim dbParam_type As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
dbParam_type.ParameterName = "@Type"
dbParam_type.Value = type
dbParam_type.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_type)
Dim dataAdapter As System.Data.IDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter
dataAdapter.SelectCommand = dbCommand
Dim dataSet As System.Data.DataSet = New System.Data.DataSet
dataAdapter.Fill(dataSet)
Return dataSet
End Function
Sub Button1_Click_1(sender As Object, e As EventArgs)
DataGrid1.DataSource = MyQueryMethod
DataGrid1.DataBind()
End Sub
Can anyone help, i know i've got to put some code into the button sub,but i just can't figure out what!