473,396 Members | 1,989 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,396 software developers and data experts.

can someone look at this?

How can i get this work going against an Oracle Table? I have it working with SQL, but when I change my db to Oracle I get an error.

The where clause is based on what is selected in the drop down box.

objConn = New OracleConnection(dbConn)
objConn.Open()
strSQL = "Select car, model from autos where car= @cars"
objDataAdapter = New OracleDataAdapter(strSQL, objConn)
'this is the error line
myCommand.Parameters.Add(New OracleParameter("@cars", OracleDbType.NVarchar2, ParameterDirection.Input))

myCommand.Parameters("@cars").Value = ddSport.SelectedValue

objDataAdapter.Fill(ds)
dgGames.DataSource = ds
dgGames.DataBind()

the error i get is
Object reference not set to an instance of an object on line 79

thanks
Nov 18 '05 #1
5 1107
What is 'myCommand'? Most likely it has not been instantiated - there is
certainly no code to instantiate it here.

"IGotYourDotNet" <IG************@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com...
How can i get this work going against an Oracle Table? I have it working with SQL, but when I change my db to Oracle I get an error.
The where clause is based on what is selected in the drop down box.

objConn = New OracleConnection(dbConn)
objConn.Open()
strSQL = "Select car, model from autos where car= @cars"
objDataAdapter = New OracleDataAdapter(strSQL, objConn)
'this is the error line
myCommand.Parameters.Add(New OracleParameter("@cars", OracleDbType.NVarchar2, ParameterDirection.Input))
myCommand.Parameters("@cars").Value = ddSport.SelectedValue

objDataAdapter.Fill(ds)
dgGames.DataSource = ds
dgGames.DataBind()

the error i get is
Object reference not set to an instance of an object on line 79

thanks

Nov 18 '05 #2
(untested)

Dim objConn As New OracleConnection(dbConn)

Dim strSQL As String = "Select car, model from autos where car=
@cars"

Dim myCommand As New OracleCommand(strSQL, objConn)
myCommand.Parameters.Add(New OracleParameter("@cars",
OracleType.NVarChar, 2)).Value = ddSport.SelectedValue

Dim objDataAdapter As New OracleDataAdapter(myCommand)

objDataAdapter.Fill(ds)
dgGames.DataSource = ds
dgGames.DataBind()
HTH,
Greg
"IGotYourDotNet" <IG************@discussions.microsoft.com> wrote in message
news:CE**********************************@microsof t.com...
How can i get this work going against an Oracle Table? I have it working with SQL, but when I change my db to Oracle I get an error.
The where clause is based on what is selected in the drop down box.

objConn = New OracleConnection(dbConn)
objConn.Open()
strSQL = "Select car, model from autos where car= @cars"
objDataAdapter = New OracleDataAdapter(strSQL, objConn)
'this is the error line
myCommand.Parameters.Add(New OracleParameter("@cars", OracleDbType.NVarchar2, ParameterDirection.Input))
myCommand.Parameters("@cars").Value = ddSport.SelectedValue

objDataAdapter.Fill(ds)
dgGames.DataSource = ds
dgGames.DataBind()

the error i get is
Object reference not set to an instance of an object on line 79

thanks

Nov 18 '05 #3
Yes, it should be:
Dim myCommand As New OracleCommand

Your code never instantiated an objec t- you only declared the variable.

NullReferenceException is always very specific to you using a variable that
has not been instantiated. That is the only time it occurs - so when it
does, check the line number and make sure that you instantiate every object
you are using.

"IGotYourDotNet" <IG************@discussions.microsoft.com> wrote in message
news:DD**********************************@microsof t.com...
this is myCommand

Dim myCommand As OracleCommand
should it be something else?

"Marina" wrote:
What is 'myCommand'? Most likely it has not been instantiated - there is
certainly no code to instantiate it here.

"IGotYourDotNet" <IG************@discussions.microsoft.com> wrote in message news:CE**********************************@microsof t.com...
How can i get this work going against an Oracle Table? I have it working
with SQL, but when I change my db to Oracle I get an error.

The where clause is based on what is selected in the drop down box.

objConn = New OracleConnection(dbConn)
objConn.Open()
strSQL = "Select car, model from autos where car= @cars"
objDataAdapter = New OracleDataAdapter(strSQL, objConn)
'this is the error line
myCommand.Parameters.Add(New OracleParameter("@cars",

OracleDbType.NVarchar2, ParameterDirection.Input))

myCommand.Parameters("@cars").Value =

ddSport.SelectedValue
objDataAdapter.Fill(ds)
dgGames.DataSource = ds
dgGames.DataBind()

the error i get is
Object reference not set to an instance of an object on line 79

thanks


Nov 18 '05 #4
Your command object has never been initiated.

Also, if you look at your code, you will see that the dataadapter is not
"tied" to the command object in anyway.

Try it this way...

Dim myCommand As New OracleCommand(strSQL, objConn)
myCommand.Parameters.Add(New OracleParameter("@cars",
OracleType.NVarChar, 2)).Value = ddSport.SelectedValue '<--- not sure about
type or size, not sure how to use NVarChar2 (and how many characters is
that, obviously not just 2 like I have here)

Dim objDataAdapter As New OracleDataAdapter(myCommand)

objDataAdapter.Fill(ds)

PS: As you can probably tell, I don't know crap about Oracle. :^) I can't
seem to import the namespace your are using. Specificly the
Oracle.DataAccess.Client.OracleDBType. Are you using the .NET provider from
MS, or one from Oracle (I assume they have their own).

Greg
"IGotYourDotNet" <IG************@discussions.microsoft.com> wrote in message
news:DD**********************************@microsof t.com...
this is myCommand

Dim myCommand As OracleCommand
should it be something else?

"Marina" wrote:
What is 'myCommand'? Most likely it has not been instantiated - there is
certainly no code to instantiate it here.

"IGotYourDotNet" <IG************@discussions.microsoft.com> wrote in message news:CE**********************************@microsof t.com...
How can i get this work going against an Oracle Table? I have it working
with SQL, but when I change my db to Oracle I get an error.

The where clause is based on what is selected in the drop down box.

objConn = New OracleConnection(dbConn)
objConn.Open()
strSQL = "Select car, model from autos where car= @cars"
objDataAdapter = New OracleDataAdapter(strSQL, objConn)
'this is the error line
myCommand.Parameters.Add(New OracleParameter("@cars",

OracleDbType.NVarchar2, ParameterDirection.Input))

myCommand.Parameters("@cars").Value =

ddSport.SelectedValue
objDataAdapter.Fill(ds)
dgGames.DataSource = ds
dgGames.DataBind()

the error i get is
Object reference not set to an instance of an object on line 79

thanks


Nov 18 '05 #5
I don't know, a wild guess... you never istantiated your ds variable either?
:^)

Dim ds As New DataSet

Greg

"IGotYourDotNet" <IG************@discussions.microsoft.com> wrote in message
news:5E**********************************@microsof t.com...
were using the provider from oracle.
I'm passing in 5 characters in to the sql statement

it keeps bombing in this line still.

objDataAdapter.Fill(ds, "cars")
"Greg Burns" wrote:
Your command object has never been initiated.

Also, if you look at your code, you will see that the dataadapter is not
"tied" to the command object in anyway.

Try it this way...

Dim myCommand As New OracleCommand(strSQL, objConn)
myCommand.Parameters.Add(New OracleParameter("@cars",
OracleType.NVarChar, 2)).Value = ddSport.SelectedValue '<--- not sure about type or size, not sure how to use NVarChar2 (and how many characters is
that, obviously not just 2 like I have here)

Dim objDataAdapter As New OracleDataAdapter(myCommand)

objDataAdapter.Fill(ds)

PS: As you can probably tell, I don't know crap about Oracle. :^) I can't seem to import the namespace your are using. Specificly the
Oracle.DataAccess.Client.OracleDBType. Are you using the .NET provider from MS, or one from Oracle (I assume they have their own).

Greg
"IGotYourDotNet" <IG************@discussions.microsoft.com> wrote in message news:DD**********************************@microsof t.com...
this is myCommand

Dim myCommand As OracleCommand
should it be something else?

"Marina" wrote:

> What is 'myCommand'? Most likely it has not been instantiated - there is > certainly no code to instantiate it here.
>
> "IGotYourDotNet" <IG************@discussions.microsoft.com> wrote in

message
> news:CE**********************************@microsof t.com...
> > How can i get this work going against an Oracle Table? I have it

working
> with SQL, but when I change my db to Oracle I get an error.
> >
> > The where clause is based on what is selected in the drop down box. > >
> >
> >
> > objConn = New OracleConnection(dbConn)
> > objConn.Open()
> > strSQL = "Select car, model from autos where car= @cars" > > objDataAdapter = New OracleDataAdapter(strSQL, objConn) > > 'this is the error line
> > myCommand.Parameters.Add(New OracleParameter("@cars",
> OracleDbType.NVarchar2, ParameterDirection.Input))
> >
> > myCommand.Parameters("@cars").Value =

ddSport.SelectedValue
> >
> > objDataAdapter.Fill(ds)
> > dgGames.DataSource = ds
> > dgGames.DataBind()
> >
> > the error i get is
> > Object reference not set to an instance of an object on line 79
> >
> > thanks
>
>
>


Nov 18 '05 #6

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

Similar topics

0
by: blockhead | last post by:
We are looking for someone to either complete a php forum program or create one for us. There isn't really anything that is available that suits our needs and we have specific wants. If you are...
5
by: Nafai | last post by:
Hello. I need to handle cin errors like these: .... int n; cout << "Type a number: "; cin >> n; // Check user actually typed a number. ....
6
by: Helmut Giese | last post by:
Hello out there, I am a rather experienced C programmer. However, today I got a javascript assignment because someone left (something like: "You're a great programmer - you'll handle this.") and I...
21
by: MLH | last post by:
A97 procedure to open http://www.arch.com/message/ enter an 800 number, press "Continue", enter a text msg string from a memo field and press "Send" This is a calendaring and appointment A97...
3
by: Amy | last post by:
Hi, I have 6 If Then Else statements I was supposed to write. I did so but I know that they have to be wrong because they all look the same. Could someone take a look at them and point me in the...
4
by: Richard L Rosenheim | last post by:
Using Visual Studio 2003 running under Windows XP Pro w/SP 1, when I create a new form, the form's title bar has the Windows 2000 look. Yet, in the various Microsoft demos, the form's title bar...
0
by: William Morgan | last post by:
i'm working on a program that downloads from news groups. it works fine on (UUE and MIME" encoded files but when you get to a yenc encoded file it messes up. the lines are all diffrent lengths...
2
by: santoshpayal | last post by:
Hi, I have a text file that contains a date column. The text file will be imported to database in SQL 2000 server. After to be importing, I want to convert the date column to date type. For...
40
by: aslamhenry | last post by:
please key in any 5 digits number : 56789 and the ouput is 5678 9 567 89 56 789 5 6789
1
by: okonita | last post by:
I need major help resolving a UDF error. My environment id DB2 UDBv8.2 and v9.1 on a Linux and Windows server. I am getting a SQL20148N error which states as follows: SQL20148N Routine...
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
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.