473,216 Members | 2,207 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,216 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 6027
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)...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

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.