473,706 Members | 2,543 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with DataAdapter.Fil l(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(ByV al 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=IBMDA 400;Data Source=" & source & _
";User ID=myID;Passwor d=myPwd;Default Connection=" & _

Collection
'Create connection object
conn400 = New OleDb.OleDbConn ection(conStr40 0)

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

'Create data adapter
da = New OleDb.OleDbData Adapter(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 4617
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(ByV al 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=IBMDA 400;Data Source=" & source & _
";User ID=myID;Passwor d=myPwd;Default Connection=" & _

Collection
'Create connection object
conn400 = New OleDb.OleDbConn ection(conStr40 0)

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

'Create data adapter
da = New OleDb.OleDbData Adapter(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
297
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 use postion property. I want to fill Dataset with just one row at a time. Please adivse!
4
1991
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 DataAdapters and create DataSets bound to them so everything is strongly typed - a very nice feature. Why in the world can this not be done the same way for ANY type of application (say, Console, or Class Library). What do these features have...
1
8500
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
1241
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 try to use any BindingContext.Count/Position methods on the dataset. Any help greatly appreciated. Error: 'Cannot create a child list for field myTable.'
9
47203
by: Nikolay Petrov | last post by:
How to fill DataSet from stored procedure?
1
4870
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
1074
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 Class WebForm1 Inherits System.Web.UI.Page Dim o_interlab As INTERLAB.CLaboratorio
6
2475
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 --------------------------------------------------------------------------------- @strProductCode nvarchar (50)
3
2312
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) SqlDataAdapterJobs.Fill(dsFormats, "formatvalues") I want to get the value for column customer_id from this dataset.
0
8692
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9276
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9141
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8982
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7895
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5934
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4705
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3140
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.