473,396 Members | 1,996 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.

DataAdapter.Fill(dataset): Null exception

Hello all,
I'm developing a web application using VB.Net 2003 and Framework 1.1. This
application queries an AS/400 database. I'm using the IBM OleDb provider
that came with IBM Client Access for Windows (V5R3). Everything works fine
on my development PC, but when I move the application to a Windows Server
2003, it crashes when trying to fill a dataset. I've double-checked that the
Win 2k3 server does have Client Access installed, that it has .NET Framework
1.1, and running IIS. The only difference between my development PC and the
2k3 Server is that my PC is running WinXP Pro (thus it runs IIS v.5.1) while
the server is running IIS v.6.0.
Here is my code:

Public Sub LoadDataSet(ByVal source As String, ByVal Collection As String, _
ByVal table As String, ByVal field As String, ByVal
keyValue As String)

'Connection string to as400 database
conStr400 = "Provider=IBMDA400;Data Source=" & source & _
";User ID=myID;Password=myPwd;DEFAULT COLLECTION=" &
Collection
'Create connection object
conn400 = New OleDb.OleDbConnection(conStr400)

'Building SQL select string
Dim selStr As String = "SELECT " & selectedFields & " FROM " & table
& _
" WHERE " & field & " = " & keyValue & " ORDER
BY DSNUMB"

'Create data adapter
da = New OleDb.OleDbDataAdapter(selStr, conn400)

Dim count As Integer = 0

'Open connection to database. The Response.Write statements are for
debugging purpose only

Response.Write("Conn State before open: " & conn400.State & "<br>")
<----- shows "0"

conn400.Open()

Response.Write("Conn State after open: " & conn400.State & "<br>")
<----- shows "1": connected

'Try to load dataset
Try
ds.Clear()

Response.Write("Before Fill: " & ds.Tables.Count & "<br>")
<----- shows "Before Fill: 0" : ds was created, just doesn't have any data,
yet.

count = da.Fill(ds) <---- Null Exception occurs here

Response.Write("After Fill: " & ds.Tables.Count & "<br>Rec count
= " & count) <----- Doesn't show anything

Catch ex As Exception

TextBox2.Text = "Fill Error: " & ex.Message <------ Shows
"Object reference not set to an instance of the object."
Finally
conn400.Close()
Response.Write("Conn State after close: " & conn400.State &
"<br>") <---- Shows "Finally: 0"
End Try
End Sub

At the line of code where that causes exception, the only objects referred
are the Data Adapter "da" and the DataSet "ds".
The dataset "ds" is not the problem because I can count the number of tables
in it before the fill. So the thing that got left is the data adapter.
Why isn't it created/instanitiated?
Please help... I'm stuck with this for the last 3 days I still can't figure
out the cause/solution for it.
Thank you very much.
Stanav.
Nov 19 '05 #1
2 6048
Stanav,

I've had trouble with this also. I've learned to only use datareaders... I
loop through the data returned and create my own dataset when necessary to
have one. I.e. when returning the dataset via a webservice.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Stanav" <st*******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hello all,
I'm developing a web application using VB.Net 2003 and Framework 1.1. This
application queries an AS/400 database. I'm using the IBM OleDb provider
that came with IBM Client Access for Windows (V5R3). Everything works fine
on my development PC, but when I move the application to a Windows Server
2003, it crashes when trying to fill a dataset. I've double-checked that
the Win 2k3 server does have Client Access installed, that it has .NET
Framework 1.1, and running IIS. The only difference between my development
PC and the 2k3 Server is that my PC is running WinXP Pro (thus it runs IIS
v.5.1) while the server is running IIS v.6.0.
Here is my code:

Public Sub LoadDataSet(ByVal source As String, ByVal Collection As String,
_
ByVal table As String, ByVal field As String, ByVal
keyValue As String)

'Connection string to as400 database
conStr400 = "Provider=IBMDA400;Data Source=" & source & _
";User ID=myID;Password=myPwd;DEFAULT COLLECTION=" &
Collection
'Create connection object
conn400 = New OleDb.OleDbConnection(conStr400)

'Building SQL select string
Dim selStr As String = "SELECT " & selectedFields & " FROM " &
table & _
" WHERE " & field & " = " & keyValue & " ORDER
BY DSNUMB"

'Create data adapter
da = New OleDb.OleDbDataAdapter(selStr, conn400)

Dim count As Integer = 0

'Open connection to database. The Response.Write statements are for
debugging purpose only

Response.Write("Conn State before open: " & conn400.State & "<br>")
<----- shows "0"

conn400.Open()

Response.Write("Conn State after open: " & conn400.State & "<br>")
<----- shows "1": connected

'Try to load dataset
Try
ds.Clear()

Response.Write("Before Fill: " & ds.Tables.Count & "<br>")
<----- shows "Before Fill: 0" : ds was created, just doesn't have any
data, yet.

count = da.Fill(ds) <---- Null Exception occurs here

Response.Write("After Fill: " & ds.Tables.Count & "<br>Rec
count = " & count) <----- Doesn't show anything

Catch ex As Exception

TextBox2.Text = "Fill Error: " & ex.Message <------ Shows
"Object reference not set to an instance of the object."
Finally
conn400.Close()
Response.Write("Conn State after close: " & conn400.State &
"<br>") <---- Shows "Finally: 0"
End Try
End Sub

At the line of code where that causes exception, the only objects referred
are the Data Adapter "da" and the DataSet "ds".
The dataset "ds" is not the problem because I can count the number of
tables in it before the fill. So the thing that got left is the data
adapter.
Why isn't it created/instanitiated?
Please help... I'm stuck with this for the last 3 days I still can't
figure out the cause/solution for it.
Thank you very much.
Stanav.

Nov 19 '05 #2
Thank you for the tip, Justin.
I'll try the datareader today and let you know the results.
Stanav.

S. Justin Gengo wrote:
Stanav,

I've had trouble with this also. I've learned to only use datareaders... I
loop through the data returned and create my own dataset when necessary to
have one. I.e. when returning the dataset via a webservice.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Stanav" <st*******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hello all,
I'm developing a web application using VB.Net 2003 and Framework 1.1. This
application queries an AS/400 database. I'm using the IBM OleDb provider
that came with IBM Client Access for Windows (V5R3). Everything works fine
on my development PC, but when I move the application to a Windows Server
2003, it crashes when trying to fill a dataset. I've double-checked that
the Win 2k3 server does have Client Access installed, that it has .NET
Framework 1.1, and running IIS. The only difference between my development
PC and the 2k3 Server is that my PC is running WinXP Pro (thus it runs IIS
v.5.1) while the server is running IIS v.6.0.
Here is my code:

Public Sub LoadDataSet(ByVal source As String, ByVal Collection As String,
_
ByVal table As String, ByVal field As String, ByVal
keyValue As String)

'Connection string to as400 database
conStr400 = "Provider=IBMDA400;Data Source=" & source & _
";User ID=myID;Password=myPwd;DEFAULT COLLECTION=" &
Collection
'Create connection object
conn400 = New OleDb.OleDbConnection(conStr400)

'Building SQL select string
Dim selStr As String = "SELECT " & selectedFields & " FROM " &
table & _
" WHERE " & field & " = " & keyValue & " ORDER
BY DSNUMB"

'Create data adapter
da = New OleDb.OleDbDataAdapter(selStr, conn400)

Dim count As Integer = 0

'Open connection to database. The Response.Write statements are for
debugging purpose only

Response.Write("Conn State before open: " & conn400.State & "<br>")
<----- shows "0"

conn400.Open()

Response.Write("Conn State after open: " & conn400.State & "<br>")
<----- shows "1": connected

'Try to load dataset
Try
ds.Clear()

Response.Write("Before Fill: " & ds.Tables.Count & "<br>")
<----- shows "Before Fill: 0" : ds was created, just doesn't have any
data, yet.

count = da.Fill(ds) <---- Null Exception occurs here

Response.Write("After Fill: " & ds.Tables.Count & "<br>Rec
count = " & count) <----- Doesn't show anything

Catch ex As Exception

TextBox2.Text = "Fill Error: " & ex.Message <------ Shows
"Object reference not set to an instance of the object."
Finally
conn400.Close()
Response.Write("Conn State after close: " & conn400.State &
"<br>") <---- Shows "Finally: 0"
End Try
End Sub

At the line of code where that causes exception, the only objects referred
are the Data Adapter "da" and the DataSet "ds".
The dataset "ds" is not the problem because I can count the number of
tables in it before the fill. So the thing that got left is the data
adapter.
Why isn't it created/instanitiated?
Please help... I'm stuck with this for the last 3 days I still can't
figure out the cause/solution for it.
Thank you very much.
Stanav.


Nov 19 '05 #3

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

Similar topics

0
by: IMRAN SAROIA | last post by:
Hi! I want to select specific row from Database in Select Query. Can any one adivse? E.g., in selection criteria I want to mention row to retrieve. Are there any alternatives. I donot want to...
1
by: PawelR | last post by:
Hello everybody, I have one littel question: How fill DataSet values witch return stored procedure? My SP have parameters. Thanks PawelR
9
by: Nikolay Petrov | last post by:
How to fill DataSet from stored procedure?
1
by: Nikolay Petrov | last post by:
How to fill dataset with multiple tables and set their relaition? Can I get the relations from the SQL server? Also I would like to do it using stored procedures. TIA
3
by: Stanav | last post by:
Hello all, I'm developing a web application using VB.Net 2003 and Framework 1.1. This application queries an AS/400 database. I'm using the IBM OleDb provider that came with IBM Client Access for...
0
by: Yoel Mc Lennan | last post by:
Hello Group, I need to obtain recordset of an object COM made in VB6 and soon fill dataset, some idea of where is the error? Thanks. Imports System.Data Imports System.Configuration Public...
6
by: Laura K | last post by:
This is probably a simple question but I want to make sure I am doing it right. I have a spoc with two select statements which results in two tables. Very Basic ...
1
by: dedipya | last post by:
Environment W2003K with Oracle 10 client connected to oracle using oracle odp provider.orcle is on solaries machine. while filling the dataset .net is throughing the error "argument was out of the...
3
by: Newbie | last post by:
Hi, I have a dataadapter that contains just a single record. Dim SqlDataAdapterValues As New SqlDataAdapter("select * from tbl_formatvalue where format_id = " & intFormatInt, dbConnectionIn)...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.