ASP.NET 2.0 Help

Capodecina
Permabanned
Joined
31 Dec 2003
Posts
5,172
Location
Barrow-In-Furness
Learning has slowed down greatly, I just can't seem to get a new field created using a DetailsView control.

I'm thinking the problem is because of the AutoNumber (ID) field in the table i'm trying to enter data into.

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

This is the insert query:

Code:
INSERT INTO [tbl_Data] ([project_code], [date], [monday], [tuesday], [wednesday], [friday], [thursday], [saturday], [sunday], [ID]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

When I click the New hyperlink on the DetailsView control it removed the ID field from view (which is ideal).

Also.... how can I autopopulate fields? For example, the ID field needs to increment in sync with the database, the date field should really autopopulate with todays current date when a new entry is being made. What if I want to make an entry for the next date today though?

Argghhhh trying to teach yourself from a book that is using SQL Express and you have to use Access is an absolute pain.

I'm probably not even being clear at all :mad:

Alternatively, if someone uses ASP.NET 2.0 and Visual Web Developer and doesn't mind helping me on MSN (don't worry I do try fix things myself first, let me know if I can add you)
 
Last edited:
You don't need to include the autonumber field if you are inserting.

This is how I store to an SQL database (I think it should still work for Access).

Code:
INSERT INTO [Table1] ([Field1], [Field2], [Field3]) VALUES (?, ?, ?);
SELECT ID, Field1, Field2, Field3 FROM Table1 WHERE (ID = SCOPE_IDENTITY())

You only include the ID in the SELECT statement if the ID is an autonumber.

The SCOPE_IDENTITY() should increment the ID field, as for adding the date just add DATE() or NOW() instead of the ? for the date value.
 
Back
Top Bottom