What Have I Done?

P

Paul Smith

I was working fine constructing a web page which contains a CheckBoxList. I had it working using the code below.

Dim FrontRow As New DataSet()

OleDbDataAdapter1.SelectCommand.CommandText = "SELECT * FROM tSNOBsPlayers"

OleDbDataAdapter1.Fill(FrontRow)

chklstFrontRow.DataSource = FrontRow

chklstFrontRow.DataTextField = "Player"

chklstFrontRow.DataValueField = "PlayerValue"

chklstFrontRow.DataBind()


As you can see I had an OleDbConnection and OleDbDataAdapter on my web form.

I then, because I did not understand their significance deleted, in the ..aspx.vb file, the code which had automatically been added (Private Sub InitializeComponent() ) when these were configured. I worked out I had done something wrong because when i built my code, as I had successfully done many times before, I got the following error:

Object reference not set to an instance of an object.

on the following line:

OleDbDataAdapter1.SelectCommand.CommandText = "SELECT * FROM tSNOBsPlayers"

I have re-added the Connection and dataAdapter but this does not seem to make any difference - what am I doing wrong, and more importantly how do I rectify it?
 
N

Nathan Sokalski

I am not entirely sure (I am not an expert on the automatically generated code), but I believe the code Private Sub InitializeComponent() is used to create the objects that are specified in the .aspx file (basically converting them from elements and attributes to objects and properties so you can get and set them in your code). This is just a guess, but I do know that the code Private Sub InitializeComponent() is always necessary.
--
Nathan Sokalski
(e-mail address removed)
http://www.nathansokalski.com/
I was working fine constructing a web page which contains a CheckBoxList. I had it working using the code below.

Dim FrontRow As New DataSet()

OleDbDataAdapter1.SelectCommand.CommandText = "SELECT * FROM tSNOBsPlayers"

OleDbDataAdapter1.Fill(FrontRow)

chklstFrontRow.DataSource = FrontRow

chklstFrontRow.DataTextField = "Player"

chklstFrontRow.DataValueField = "PlayerValue"

chklstFrontRow.DataBind()


As you can see I had an OleDbConnection and OleDbDataAdapter on my web form.

I then, because I did not understand their significance deleted, in the .aspx.vb file, the code which had automatically been added (Private Sub InitializeComponent() ) when these were configured. I worked out I had done something wrong because when i built my code, as I had successfully done many times before, I got the following error:

Object reference not set to an instance of an object.

on the following line:

OleDbDataAdapter1.SelectCommand.CommandText = "SELECT * FROM tSNOBsPlayers"

I have re-added the Connection and dataAdapter but this does not seem to make any difference - what am I doing wrong, and more importantly how do I rectify it?
 
J

John Rivers

Write a windows batch file
that zip's your source code to a file with a timestamped filename
and put shortcut to it in your start menu

before you start work in the morning
run the batch

before you delete a bunch of stuff that you are not sure about
run the batch

before you leave at night
run the batch

my batch also copies the zip file to 2 remote locations

now you are safe

from a million problems

and can have a happy career developing without fear

and when you can retire, you will be able to say

i never lost any data - EVER

and you would know the answer to your question :)
 
G

Guest

John Rivers said:
Write a windows batch file
that zip's your source code to a file with a timestamped filename
and put shortcut to it in your start menu
<snip>

Or just use a source control repository (e.g. VSS) :-s
 
J

John Rivers

that would have been a fair response
except for the word "just"

learning, setting up, maintaining, backing up and disaster
recovery of vss/cvs is no small matter

anybody would be crazy to use a source code repository
unless they either had someone to maintain it for them
or knew it inside out themselves

kiss
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top