473,324 Members | 2,002 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,324 software developers and data experts.

Problem With DataAdapter

I am trying to fill a dataset with a list of user tables from an Access
database. When I run the code (below) I get an error on the myDA1.Fill line.
The error message is: "Value cannot be null".

If I copy and paste the SQL string into an Access query it works fine. The
connection string is valid (used in another case).

Any thoughts on what might cause this.

====================================
Dim myDS1 As DataSet

Dim row As DataRow

Dim strTemp As String

strTemp = "SELECT MSysObjects.Name FROM MSysObjects WHERE " & _

" (((MSysObjects.Name) Not Like 'MSys%') AND " & _

" ((MSysObjects.Type)=1)) ORDER BY MSysObjects.Name"

Dim myDA1 As New OleDb.OleDbDataAdapter(strTemp, mConnStr)

Dim ii As Integer = 0

myDA1.Fill(myDS1, "AllTables")
--
------------------------------------
Wayne Wengert
wa***@wengert.org
Jul 19 '05 #1
5 1948
It sounds like there is a field in your table in your
dataset which does not allow nulls. You can retrieve the
records from the database but you cannot insert them into
your dataset table because of this. If this is the case
you would be able to run the query in access or sql with
no problems but not fill your dataset. You will need to
modify your dataset table to allow nulls for the field
causing the error.

If you look in the vb code generated for your dataset you
will find an InitClass() sub. In here is where you set
which columns you want to allow dbnull.

Change it to say:
Me.Column??.AllowDBNull = True

Hope this helps,

Billy Jacobs
-----Original Message-----
I am trying to fill a dataset with a list of user tables from an Accessdatabase. When I run the code (below) I get an error on the myDA1.Fill line.The error message is: "Value cannot be null".

If I copy and paste the SQL string into an Access query it works fine. Theconnection string is valid (used in another case).

Any thoughts on what might cause this.

====================================
Dim myDS1 As DataSet

Dim row As DataRow

Dim strTemp As String

strTemp = "SELECT MSysObjects.Name FROM MSysObjects WHERE " & _
" (((MSysObjects.Name) Not Like 'MSys%') AND " & _

" ((MSysObjects.Type)=1)) ORDER BY MSysObjects.Name"

Dim myDA1 As New OleDb.OleDbDataAdapter(strTemp, mConnStr)

Dim ii As Integer = 0

myDA1.Fill(myDS1, "AllTables")
--
------------------------------------
Wayne Wengert
wa***@wengert.org
.

Jul 19 '05 #2
I'll check on that. Thanks for the suggestion.

Wayne

"Billy Jacobs" <bi********@csa.com> wrote in message
news:00****************************@phx.gbl...
It sounds like there is a field in your table in your
dataset which does not allow nulls. You can retrieve the
records from the database but you cannot insert them into
your dataset table because of this. If this is the case
you would be able to run the query in access or sql with
no problems but not fill your dataset. You will need to
modify your dataset table to allow nulls for the field
causing the error.

If you look in the vb code generated for your dataset you
will find an InitClass() sub. In here is where you set
which columns you want to allow dbnull.

Change it to say:
Me.Column??.AllowDBNull = True

Hope this helps,

Billy Jacobs
-----Original Message-----
I am trying to fill a dataset with a list of user tables

from an Access
database. When I run the code (below) I get an error on

the myDA1.Fill line.
The error message is: "Value cannot be null".

If I copy and paste the SQL string into an Access query

it works fine. The
connection string is valid (used in another case).

Any thoughts on what might cause this.

====================================
Dim myDS1 As DataSet

Dim row As DataRow

Dim strTemp As String

strTemp = "SELECT MSysObjects.Name FROM MSysObjects

WHERE " & _

" (((MSysObjects.Name) Not Like 'MSys%') AND " & _

" ((MSysObjects.Type)=1)) ORDER BY MSysObjects.Name"

Dim myDA1 As New OleDb.OleDbDataAdapter(strTemp, mConnStr)

Dim ii As Integer = 0

myDA1.Fill(myDS1, "AllTables")
--
------------------------------------
Wayne Wengert
wa***@wengert.org
.

Jul 19 '05 #3
Hello Wayne,

Thanks for your post.
From your code snippet, you declared a DataSet variable without creating a
new instance of the DataSet. If so, I believe the exception is caused by
it, and you should instanciate DataSet:

Dim myDS1 As DataSet
myDS1 = new DataSet()

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! ¨C www.microsoft.com/security
This posting is provided ¡°as is¡± with no warranties and confers no rights.
Jul 19 '05 #4
Thanks. I still am very confused with the wonderful world of OO - when to
Dim, when to use "New", etc. etc.

I'll try the change you suggest

Wayne

"Tian Min Huang" <ti******@online.microsoft.com> wrote in message
news:on**************@cpmsftngxa06.phx.gbl...
Hello Wayne,

Thanks for your post.
From your code snippet, you declared a DataSet variable without creating a
new instance of the DataSet. If so, I believe the exception is caused by
it, and you should instanciate DataSet:

Dim myDS1 As DataSet
myDS1 = new DataSet()

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! ¨C www.microsoft.com/security
This posting is provided ¡°as is¡± with no warranties and confers no rights.

Jul 19 '05 #5
Hello Wayne,

I am very glad to hear that the problem was resolved!

In addition, I recommend you the following documentation on Visual Basic
"New" expression:
Visual Basic Language Specification: 9.6 New Expressions
http://msdn.microsoft.com/library/de...us/vbls7/html/
vblrfVBSpec9_6.asp?frame=true

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! ¨C www.microsoft.com/security
This posting is provided ¡°as is¡± with no warranties and confers no rights.
Jul 19 '05 #6

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

Similar topics

2
by: hch | last post by:
dataAdapter.Update(data, "TableName") won’t work! I was about to deploy my first website on the Internet only to discover that the dataAdapter.Update() throws the Server Error in the third...
0
by: Greenwich Support | last post by:
Hi All, I have a very weird problem which is occurring with a VB.Net app and PostgreSQL 7.3.1. There is a form that has a standard .Net datagrid on it that contains some data from a table in...
1
by: Steven Blair | last post by:
Hi, Here is a short decsription of my problem. I have written a dll for Database accessing. I have one method which can return a Dataset and another method which takes a Dataset and upates a...
0
by: Steve Bishop | last post by:
I have a form with a search text box and a grid that displays the results. Within the grid, I have edit command links set up to response.redirect to another page that puts the DataKey value in the...
3
by: crjunk | last post by:
I have 4 different databases that I'm having to pull data from in order to populate a datagrid. I am able to do this, but my problem is that because I'm pulling the data from 4 different...
11
by: Siv | last post by:
Hi, I seem to be having a problem with a DataAdapter against an Access database. My app deletes 3 records runs a da.update(dt) where dt is a data.Datatable. I then proceed to update a list to...
3
by: Rich | last post by:
What is the diffeence bewtween a dataAdapter.InsertCommand and dataAdapter.SelectCommand (and dataAdapter.UpdateCommand for that matter)? Dim da As SqlDataAdapter conn.Open da.SelectCommand =...
5
by: Emil | last post by:
I've created a very simple data base in Microsoft Access 2003. It consists of only one table called "Students" and it contains 2 information about each student: id-student and name. When I try...
1
by: BobLewiston | last post by:
I’m trying to learn how to connect to an SQL Server database (I’m using the AdventureWorks sample database), but I’m having problems. Here’s the code I’m using: // define connection string for...
2
by: BobLewiston | last post by:
I can read in an SQL table ("Person.Contact") from AdventureWorks and step through it one row at a time, but when I try to save a record, either one I'm inserting or one I'm editting, I get the...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.