Friday, March 16, 2012

Passing a Variable?

Hi All,

Having an issue when passin a variable form one page to another.....can anyone please make this headache go away by point out the eror of my ways..Have a feeling its sql statement.......(as always!!!!)

Any help would be most appreciated,,

Cheers

Tony

CODE

Dim lota as string
Public strSearch as string
Public strSearcha as string
Dim counta as string

Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)

lota = Request.QueryString("lota")

If Not Page.IsPostBack Then
'if Not IsPostBack Then
Dim DBConn as OleDbConnection
Dim DBCommand As OleDbDataAdapter
Dim DSPageData as New DataSet
DBConn = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
& "DATA SOURCE=" _
& Server.MapPath("/fpdb/" _
& "auction.mdb;"))
DBCommand = New OleDbDataAdapter _
("Select Distinct LotDescription " _
& "From Table1 " _
& "Where Date = & lota & "
& "Order By LotDescription", DBConn)
DBCommand.Fill(DSPageData, _
"LotDescription")
ddlZipCode.DataSource = _
DSPageData.Tables("LotDescription").DefaultView
ddlZipCode.DataBind()
dbconn.close
end if
end sub

Error Message

Server Error in '/' Application.
------------------------

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30311: Value of type 'String' cannot be converted to 'System.Data.OleDb.OleDbCommand'.

Source Error:

Line 30: & "auction.mdb;"))
Line 31: DBCommand = New OleDbDataAdapter _
Line 32: ("Select Distinct LotDescription " _
Line 33: & "From Table1 " _
Line 34: & "Where Date = & lota & "you need to create an additional object of type OleDbCommand.


Dim DBcommand As New OleDb.OleDbCommand
DBcommand.CommandText = "select * from table1"
DBAdapter = new OleDbDataAdapter(DBcommand)

0 comments:

Post a Comment