Answered by:
BC30456: 'datasource' is not a member of 'System.Data.OleDb.OleDbDataReader'.

Question
-
User1738169615 posted
This is the code:
Sub Page_Load()
Dim strconnection As OleDbConnection
Dim sql As String
Dim dbcomm As OleDbCommand
Dim dbread As OleDbDataReader
Dim PurchasesL_Term As OleDbDataReader
strconnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & Server.MapPath("App_Data/LondonCarParks.mdb"))
strconnection.Open()
sql = "SELECT * FROM PurchasesL_Term"
dbcomm = New OleDbCommand(sql, strconnection)
dbread = dbcomm.ExecuteReader()
dbread = PurchasesL_Term.datasource
PurchasesL_Term.DataBind()
dbread.Close()
strconnection.Close()
End Sub
Protected Sub cmdSubmitLong_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Try
Dim strconnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;data source=" & Server.MapPath("App_Data/LondonCarParks.mdb")
Dim objconnection As New OleDbConnection(strconnection)
Dim strsql As String = "insert into PurchasesL_Term(Firstname,Surname,E-MailAddress,StationName,SpaceNumber,StartDate,Days,EndDate,CreditCardNumber,ValidFrom,Expiresend,CardType,Cost) values('" & txtFirstNameLong.Text & "','" & txtSurnameLong.Text & "','" & txtEMailLong.Text & "','" & lstStationsLong.Text & "','" & lstSpaceNumberLong.Text & "','" & txtDateLong.Text & "','" & lstDaysLong.Text & "','" & txtDateFinishedLong.Text & "','" & txtCCardDetailsLong.Text & "','" & txtStartDateLong.Text & "','" & txtEndDateLong.Text & "','" & lstCCardTypeLong.Text & "','" & txtCostLong.Text & "')"
Dim objcommand As New OleDbCommand(strsql, objconnection)
objconnection.Open()
objcommand = New OleDbCommand(strsql, objconnection)
objcommand.ExecuteNonQuery()
objconnection.Close()
Catch ex As Exception
End Try
End Sub
The following error message is:
file:///C:/Documents%20and%20Settings/Lee/Desktop/untitled.bmp
Please can soemone explain why this is happening
Friday, March 6, 2009 7:44 AM
Answers
-
User-821857111 posted
OK. You are selecting data at that point. You would then normally bind the selected data to a databound control for display in a web page. To do this, you set the DataSource property of the control to point to the DataReader that contains the data. You can't "bind" it to a table in your database. That makes no sense.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, March 10, 2009 8:07 AM
All replies
-
User-821857111 posted
dbread = PurchasesL_Term.datasourceChange the above around:
PurchasesL_Term.datasource = dbread
Then read this: http://www.mikesdotnetting.com/Article.aspx?ArticleID=26
Friday, March 6, 2009 8:18 AM -
User1738169615 posted
changed that but still comes up with error mssage
"Object variable or With block variable not set."
Friday, March 6, 2009 10:11 AM -
User-821857111 posted
Which line throws the error?
Friday, March 6, 2009 2:48 PM -
User1738169615 posted
PurchasesL_Term.datasource = dbread is the lineSaturday, March 7, 2009 1:35 PM -
User-821857111 posted
Is PurchasesL_Term a GridView or other DataBound ASP.NET control?
Saturday, March 7, 2009 3:08 PM -
User1738169615 posted
Its my table where the form data will be stored in name so databound
Tuesday, March 10, 2009 7:19 AM -
User-821857111 posted
OK. You are selecting data at that point. You would then normally bind the selected data to a databound control for display in a web page. To do this, you set the DataSource property of the control to point to the DataReader that contains the data. You can't "bind" it to a table in your database. That makes no sense.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, March 10, 2009 8:07 AM