Access DB error message when using ASP.NET 2.0

R

Richard Finnigan

Hi

I was wondering if anyone could help me with this problem. I've been using
VWD and my webhost ( a shared hosting package) have told me that the MSQL
express files wont work on thier server so I've tried switching to Access
and I cant add or delete new records either locally or on thier server.

I keep getting this error message.

"You tried to assign the Null value to a variable that is not a Variant data
type"

I've had a look at folder permissions and field data types.

Any help would be welcome.

Regards
 
J

Juan T. Llibre

Hi, Richard.

Access data types include Boolean, Integer, Long,
Currency, Single, Double, Date, String, and Variant.

The Variant data type, in Access, is the default.

That error is caused by what the error message says:
only Variant data type variables can be assigned a Null value.

There's at least a couple of possible causes for that error.

1.
A control on a form that has had nothing entered has the value Null,
so you're submitting a null string value (which is not of the Variant type).

An easy way to fix that is to use the text box's BeforeUpdate event to check for data.

Private Sub txtName_BeforeUpdate(Cancel As Integer)

If IsNull(Me.txtName) Then
' display an alert telling the user that some data is needed for the field
Cancel = True
End If
End Sub

However, it's more probable that your problem is :

2.
When you insert a row into a table that has an autonumber field,
you don't need to include that field name in your insert statement.

See : http://forums.asp.net/thread/1239942.aspx
for a pointer on how to fix that.

This link also has a clear example of what you need to do:
http://forums.hostmysite.com/post-8420.html

Please post back and tell us whether one of those two possible solutions fixed your problem.
 
R

Richard Finnigan

Juan T. Llibre said:
Hi, Richard.

Access data types include Boolean, Integer, Long,
Currency, Single, Double, Date, String, and Variant.

The Variant data type, in Access, is the default.

That error is caused by what the error message says:
only Variant data type variables can be assigned a Null value.

There's at least a couple of possible causes for that error.

1.
A control on a form that has had nothing entered has the value Null,
so you're submitting a null string value (which is not of the Variant
type).

An easy way to fix that is to use the text box's BeforeUpdate event to
check for data.

Private Sub txtName_BeforeUpdate(Cancel As Integer)

If IsNull(Me.txtName) Then
' display an alert telling the user that some data is needed for the
field
Cancel = True
End If
End Sub

However, it's more probable that your problem is :

2.
When you insert a row into a table that has an autonumber field,
you don't need to include that field name in your insert statement.

See : http://forums.asp.net/thread/1239942.aspx
for a pointer on how to fix that.

This link also has a clear example of what you need to do:
http://forums.hostmysite.com/post-8420.html

Please post back and tell us whether one of those two possible solutions
fixed your problem.
Hi Julian

Thanks for your help with this problem, It was the second issue and
removing references to the ID field fixed it.

I've now hit the folder permissions issue on the remote website :(

Hayho.

Richard Finnigan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,150
Latest member
MakersCBDReviews
Top