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

Problem with DataAdapter.Fill(Dataset)

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 Connection=" & _

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)
'>>> Shows "Finally: 0" : disconnected
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 23 '05 #1
3 4595
Stanav wrote:
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 Connection=" & _

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)
'>>> Shows "Finally: 0" : disconnected
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.


Are you quering the same data on your machine and the server? My gut
says that it is a problem in the data that is being retrieved and not in
the da or ds objects.

Chris
Nov 23 '05 #2
Thanks for replying to my post, Chris.
And yes, I'm quering the same data on both machines.
I'm still stuck on this... Any other suggestions/ideas?

Nov 23 '05 #3
Stanav,

My idea says me that you are getting the data with two different users.

Can that not be the problem?

(Although you have your connection to the database, can the database maybe
be restricted)

Just a guess

Cor
Nov 23 '05 #4

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...
4
by: Adam Clauss | last post by:
This may be more of a Visual Studio question than a C# question, but it came up within the context of a C# app, so here it is. In a Windows Form or a Web Form application, you can drag various...
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
2
by: Rich | last post by:
Hi, I've done a drag and drop of a sqlDataAdapter and generated a dataset on a second WinForm (Form2) I'm opening as a dialog box. I can bind to it and retrieve results but I get an error when I...
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
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 ...
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
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
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
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
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.