473,395 Members | 1,941 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Am I blind?

Roy
Sorry for the sea of code. For no apparent reason that I can tell, this
section of code began producing an "Object reference not set to an
instance of an object." error. The error occurs on the line I indicate
below. The code below is nothing in-depth, some variables and a darn
editable datagrid... I just don't get it.


FVDConnection = New
SqlConnection("server=localhost;uid=itv;pwd=;datab ase=test")
Dim strSQLQuery As String

'Assign variables to columns
Dim strBook As String = CType(e.Item.Cells(1).Controls(0),
TextBox).Text
Dim strVan As String = CType(e.Item.Cells(2).Controls(0), TextBox).Text
Dim strContNum as String = CType(e.Item.Cells(3).Controls(0),
TextBox).Text
Dim strVDN as String = CType(e.Item.Cells(4).Controls(0), TextBox).Text
Dim strPoE as String = CType(e.Item.Cells(5).Controls(0), TextBox).Text
Dim strShipName as String = CType(e.Item.Cells(6).Controls(0),
TextBox).Text
Dim strPod as String = CType(e.Item.Cells(8).Controls(0), TextBox).Text
Dim strCarrier As String = CType(e.Item.Cells(9).Controls(0),
TextBox).Text
Dim strPCFN as String = CType(e.Item.Cells(10).Controls(0),
TextBox).Text
Dim strTCN as String = CType(e.Item.Cells(11).Controls(0),
TextBox).Text
Dim strLastEvent As String = CType(e.Item.Cells(12).Controls(0),
TextBox).Text
Dim strLELoc as String = CType(e.Item.Cells(13).Controls(0),
TextBox).Text
Dim strLEShipName as String = CType(e.Item.Cells(15).Controls(0),
TextBox).Text
Dim strLESCAC as String = CType(e.Item.Cells(16).Controls(0),
TextBox).Text
Dim strCCity as String = CType(e.Item.Cells(17).Controls(0),
TextBox).Text
Dim strRecon as String = CType(e.Item.Cells(18).Controls(0),
TextBox).Text
********ERROR OCCURS ON FIRST LINE OF THIS strSQLQuery statement***

strSQLQuery = "UPDATE [firstvd] " & _
"SET carrier_booking_nr = N'" & Replace(strBook.Trim, "'", "''") & "',
" & _
"van_owner = '" & Replace(strVan.Trim, "'", "''") & "', " & _
"tcon_container_num = N'" & Replace(strContNum.Trim, "'", "''") & "', "
& _
"voydoc = '" & Replace(strVDN.Trim, "'", "''") & "', " & _
"poe = '" & Replace(strPoE.Trim, "'", "''") & "', " & _
"Ship_Name = '" & Replace(strShipName.Trim, "'", "''") & "', " & _
"pod = '" & Replace(strPoD.Trim, "'", "''") & "', " & _
"ocean_carrier_cd = N'" & Replace(strCarrier.Trim, "'", "''") & "', " &
_
"PCFN = '" & Replace(strPCFN.Trim, "'", "''") & "', " & _
"tcn = '" & Replace(strTCN.Trim, "'", "''") & "', " & _
"lastevent = '" & Replace(strLastEvent.Trim, "'", "''") & "', " & _
"lasteventloc = '" & Replace(strLELoc.Trim, "'", "''") & "', " & _
"Lastevent_shipname = N'" & Replace(strLEShipName.Trim, "'", "''") &
"', " & _
"lastevent_scac = N'" & Replace(strLEScac.Trim, "'", "''") & "', " & _
"consigneecity = N'" & Replace(strCCity.Trim, "'", "''") & "', " & _
"Recon_Status = '" & Replace(strRecon.Trim, "'", "''") & "' " & _
"WHERE carrier_booking_nr = '"& strPreBook.Trim & "' AND van_owner =
'"& strPreVan.Trim &"' AND tcon_container_num = '"& strPreCNUM.Trim
&"'"

FVDConnection.Open()
Dim objCommand As SqlCommand = New SqlCommand(strSQLQuery,
FVDConnection)
objCommand.ExecuteNonQuery()
FVDConnection.Close()

Nov 19 '05 #1
5 1109
BG
How about something like this?

Sub DataGrid1_Update(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs) Handles DataGrid1.UpdateCommand
Dim strBook As String =
Convert.ToString(CType(e.Item.FindControl("textBox Name"), TextBox).Text)
TextBox).Text

End Sub

"Roy" <ro**********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Sorry for the sea of code. For no apparent reason that I can tell, this
section of code began producing an "Object reference not set to an
instance of an object." error. The error occurs on the line I indicate
below. The code below is nothing in-depth, some variables and a darn
editable datagrid... I just don't get it.


FVDConnection = New
SqlConnection("server=localhost;uid=itv;pwd=;datab ase=test")
Dim strSQLQuery As String

'Assign variables to columns
Dim strBook As String = CType(e.Item.Cells(1).Controls(0),
TextBox).Text
Dim strVan As String = CType(e.Item.Cells(2).Controls(0), TextBox).Text
Dim strContNum as String = CType(e.Item.Cells(3).Controls(0),
TextBox).Text
Dim strVDN as String = CType(e.Item.Cells(4).Controls(0), TextBox).Text
Dim strPoE as String = CType(e.Item.Cells(5).Controls(0), TextBox).Text
Dim strShipName as String = CType(e.Item.Cells(6).Controls(0),
TextBox).Text
Dim strPod as String = CType(e.Item.Cells(8).Controls(0), TextBox).Text
Dim strCarrier As String = CType(e.Item.Cells(9).Controls(0),
TextBox).Text
Dim strPCFN as String = CType(e.Item.Cells(10).Controls(0),
TextBox).Text
Dim strTCN as String = CType(e.Item.Cells(11).Controls(0),
TextBox).Text
Dim strLastEvent As String = CType(e.Item.Cells(12).Controls(0),
TextBox).Text
Dim strLELoc as String = CType(e.Item.Cells(13).Controls(0),
TextBox).Text
Dim strLEShipName as String = CType(e.Item.Cells(15).Controls(0),
TextBox).Text
Dim strLESCAC as String = CType(e.Item.Cells(16).Controls(0),
TextBox).Text
Dim strCCity as String = CType(e.Item.Cells(17).Controls(0),
TextBox).Text
Dim strRecon as String = CType(e.Item.Cells(18).Controls(0),
TextBox).Text
********ERROR OCCURS ON FIRST LINE OF THIS strSQLQuery statement***

strSQLQuery = "UPDATE [firstvd] " & _
"SET carrier_booking_nr = N'" & Replace(strBook.Trim, "'", "''") & "',
" & _
"van_owner = '" & Replace(strVan.Trim, "'", "''") & "', " & _
"tcon_container_num = N'" & Replace(strContNum.Trim, "'", "''") & "', "
& _
"voydoc = '" & Replace(strVDN.Trim, "'", "''") & "', " & _
"poe = '" & Replace(strPoE.Trim, "'", "''") & "', " & _
"Ship_Name = '" & Replace(strShipName.Trim, "'", "''") & "', " & _
"pod = '" & Replace(strPoD.Trim, "'", "''") & "', " & _
"ocean_carrier_cd = N'" & Replace(strCarrier.Trim, "'", "''") & "', " &
_
"PCFN = '" & Replace(strPCFN.Trim, "'", "''") & "', " & _
"tcn = '" & Replace(strTCN.Trim, "'", "''") & "', " & _
"lastevent = '" & Replace(strLastEvent.Trim, "'", "''") & "', " & _
"lasteventloc = '" & Replace(strLELoc.Trim, "'", "''") & "', " & _
"Lastevent_shipname = N'" & Replace(strLEShipName.Trim, "'", "''") &
"', " & _
"lastevent_scac = N'" & Replace(strLEScac.Trim, "'", "''") & "', " & _
"consigneecity = N'" & Replace(strCCity.Trim, "'", "''") & "', " & _
"Recon_Status = '" & Replace(strRecon.Trim, "'", "''") & "' " & _
"WHERE carrier_booking_nr = '"& strPreBook.Trim & "' AND van_owner =
'"& strPreVan.Trim &"' AND tcon_container_num = '"& strPreCNUM.Trim
&"'"

FVDConnection.Open()
Dim objCommand As SqlCommand = New SqlCommand(strSQLQuery,
FVDConnection)
objCommand.ExecuteNonQuery()
FVDConnection.Close()

Nov 19 '05 #2
On 2 Feb 2005 17:11:24 -0800, Roy <ro**********@gmail.com> wrote:
Sorry for the sea of code. For no apparent reason that I can tell, this
section of code began producing an "Object reference not set to an
instance of an object." error. The error occurs on the line I indicate
below. The code below is nothing in-depth, some variables and a darn
editable datagrid... I just don't get it.


FVDConnection = New
SqlConnection("server=localhost;uid=itv;pwd=;datab ase=test")
Dim strSQLQuery As String

'Assign variables to columns
Dim strBook As String = CType(e.Item.Cells(1).Controls(0),
TextBox).Text
Dim strVan As String = CType(e.Item.Cells(2).Controls(0), TextBox).Text
Dim strContNum as String = CType(e.Item.Cells(3).Controls(0),
TextBox).Text
Dim strVDN as String = CType(e.Item.Cells(4).Controls(0), TextBox).Text
Dim strPoE as String = CType(e.Item.Cells(5).Controls(0), TextBox).Text
Dim strShipName as String = CType(e.Item.Cells(6).Controls(0),
TextBox).Text
Dim strPod as String = CType(e.Item.Cells(8).Controls(0), TextBox).Text
Dim strCarrier As String = CType(e.Item.Cells(9).Controls(0),
TextBox).Text
Dim strPCFN as String = CType(e.Item.Cells(10).Controls(0),
TextBox).Text
Dim strTCN as String = CType(e.Item.Cells(11).Controls(0),
TextBox).Text
Dim strLastEvent As String = CType(e.Item.Cells(12).Controls(0),
TextBox).Text
Dim strLELoc as String = CType(e.Item.Cells(13).Controls(0),
TextBox).Text
Dim strLEShipName as String = CType(e.Item.Cells(15).Controls(0),
TextBox).Text
Dim strLESCAC as String = CType(e.Item.Cells(16).Controls(0),
TextBox).Text
Dim strCCity as String = CType(e.Item.Cells(17).Controls(0),
TextBox).Text
Dim strRecon as String = CType(e.Item.Cells(18).Controls(0),
TextBox).Text
********ERROR OCCURS ON FIRST LINE OF THIS strSQLQuery statement***

strSQLQuery = "UPDATE [firstvd] " & _
"SET carrier_booking_nr = N'" & Replace(strBook.Trim, "'", "''") & "',
" & _
"van_owner = '" & Replace(strVan.Trim, "'", "''") & "', " & _
"tcon_container_num = N'" & Replace(strContNum.Trim, "'", "''") & "', "
& _
"voydoc = '" & Replace(strVDN.Trim, "'", "''") & "', " & _
"poe = '" & Replace(strPoE.Trim, "'", "''") & "', " & _
"Ship_Name = '" & Replace(strShipName.Trim, "'", "''") & "', " & _
"pod = '" & Replace(strPoD.Trim, "'", "''") & "', " & _
"ocean_carrier_cd = N'" & Replace(strCarrier.Trim, "'", "''") & "', " &
_
"PCFN = '" & Replace(strPCFN.Trim, "'", "''") & "', " & _
"tcn = '" & Replace(strTCN.Trim, "'", "''") & "', " & _
"lastevent = '" & Replace(strLastEvent.Trim, "'", "''") & "', " & _
"lasteventloc = '" & Replace(strLELoc.Trim, "'", "''") & "', " & _
"Lastevent_shipname = N'" & Replace(strLEShipName.Trim, "'", "''") &
"', " & _
"lastevent_scac = N'" & Replace(strLEScac.Trim, "'", "''") & "', " & _
"consigneecity = N'" & Replace(strCCity.Trim, "'", "''") & "', " & _
"Recon_Status = '" & Replace(strRecon.Trim, "'", "''") & "' " & _
"WHERE carrier_booking_nr = '"& strPreBook.Trim & "' AND van_owner =
'"& strPreVan.Trim &"' AND tcon_container_num = '"& strPreCNUM.Trim
&"'"

FVDConnection.Open()
Dim objCommand As SqlCommand = New SqlCommand(strSQLQuery,
FVDConnection)
objCommand.ExecuteNonQuery()
FVDConnection.Close()


well, I don't have time to cross-check them all, but I believe I see 15
variable declarations, but you have 19 variables concatenated into your
SQL string...make sure all variables are declared and initialized
properly, as one of your .Trim statements is failing due to a null
variable...

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 19 '05 #3
Roy
Hrmm. As you two correctly guessed (forgot to mention it), the code
above is within the update command of my datagrid. BG, I'll give it a
try and get back to ya. Craig, the missing declarations are globals and
are set = fields in the edit command of my datagrid. I have to pre-set
them before the user edits the table so the query updates the right
record. I've done a response write on the globals and they're all
pulling the right data when the edit button is clicked...

Here's another tip, btw, the error doesn't kick off until the Update
button is clicked and the update command is activated. Besides that,
the page runs fine. Talk about frustrating.

Nov 19 '05 #4
Roy
Interesting...

I've figured out *how* the error is being caused, I'm just clueless as
to *why.* You were right about the .Trim statements Craig. Here's the
scoop:

The error occurs in the last line of the strSQLQuery: "WHERE
carrier_booking_nr = '"& strPreBook.Trim & "' AND van*_owner = '"&
strPreVan.Trim &"' AND tcon_container_num = '"& strPreCN*UM.Trim &"'"

The system isn't seeing the values of these 3 global variables values.
I declare and initialize them as demonstrated simplisticly here:

--Class
----Declare Global Var's

----Sub edit_command
-------set GV's = to the correct grid cells

----Sub update_command
-------kick off query which fails to work because it sees the GV's as
being null

Now, using a response.write I can tell the GV's are being set within
the edit_command, by why isn't their value carrying over to the
update_command? I have enableviewstate = "true," what else can I do
short of setting them equal to session variables, which I'd rather not
do...

Any ideas, theories, etc...?

Nov 19 '05 #5
Roy
Server is a workstation running windows server 2003 which one other
developer is using as well as his test station. Could he have
inadvertantly changed a setting in sql server or IIS that generates
such errors?

I'm clueless at this point, just grasping at straws...

Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Hats | last post by:
Catholic Exorcism Failed Exorcism: The Blind Leading The Blind Subject: Re: Catholic Exorcisms Date: 1997/10/12 SEVERAL EXORCISMS
0
by: Dave | last post by:
To substring in Python: >>> name="Notlob" >>> print name lo Cooler than I could imagine...
4
by: Zachary | last post by:
Hello, I'm a blind non-programmer trying to learn Python. I've got python 2.3 for windows, but the problem is that Idle doesn't seem to work two well with my screen reading program. Is notepad,...
0
by: Harlan Messinger | last post by:
The state of New York settled with Priceline.com and Ramada.com over charges that their web sites don't meet the needs of disabled customers as required under the Americans with Disabilities Act: ...
0
by: Hats | last post by:
Catholic Exorcism Failed Exorcism: The Blind Leading The Blind Subject: Re: Catholic Exorcisms Date: 1997/10/12 SEVERAL EXORCISMS...
0
by: Ringo | last post by:
Catholic Exorcism Failed Exorcism: The Blind Leading The Blind Subject: Re: Catholic Exorcisms Date: 1997/10/12 SEVERAL EXORCISMS
6
by: MLH | last post by:
I want to be able to read the file size of my config.sys file or other file from withing Access Basic module. I'm sure its already been done. Don't wanna reinvent wheel or lug nuts, etc.
5
by: Shelly | last post by:
I am running into a strange problem with blind carbon copy. I specify two addresses, one for the sendto and one for the bcc (both are mine). It sends two emails, but BOTH are to the sendto...
1
by: matrix0978 | last post by:
Hey guys, I just found this community and its great! But im using script.aculo.us and prototype and on a site i am looking to use for my portfolio, is there anyway i could use the...
1
by: JSievers | last post by:
Hallo. A good friend of me develops web suites, for example his own at: www.augenpunkte.de. As you can see there my friend is blind and also he uses a Braille-line to develop these projects. For...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.