Reputation: 97
I am getting this error
You tried to assign the Null value to a variable that is not a Variant data type.
This is the code:
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/videogames.accdb"
DeleteCommand="DELETE FROM [Table1] WHERE [ID] = ?"
InsertCommand="INSERT INTO [Table1] ( ID,Name, ScreenName, Age, Game, YearsPlaying) VALUES (?, ?, ?, ?, ?, ?)"
SelectCommand="SELECT * FROM [Table1]"
UpdateCommand="UPDATE [Table1] SET [Name] = ?, [ScreenName] = ?, [Age] = ?, [Game] = ?, [YearsPlaying] = ? WHERE [ID] = ?">
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="ID" Type="Int32" />
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="ScreenName" Type="String" />
<asp:Parameter Name="Age" Type="Int32" />
<asp:Parameter Name="Game" Type="String" />
<asp:Parameter Name="YearsPlaying" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="Name" Type="String" />
<asp:Parameter Name="ScreenName" Type="String" />
<asp:Parameter Name="Age" Type="Int32" />
<asp:Parameter Name="Game" Type="String" />
<asp:Parameter Name="YearsPlaying" Type="String" />
<asp:Parameter Name="ID" Type="Int32" />
</UpdateParameters>
I've been over this and I can not get it to work right. Can someone please help me? Thanks.
When I tried to delete the insert parameters with the Id it comes back with a different error.
Upvotes: 0
Views: 530
Reputation: 17370
It might be because in the insert you have the ID while it could be an Autonumeric in the database. Try removing it from the Insert Command. Good luck!
Upvotes: 3
Reputation: 20617
Remove the ID
InsertParameter
:
<asp:Parameter Name="ID" Type="Int32" />
Change your InsertCommand
:
InsertCommand="INSERT INTO [Table1] (Name, ScreenName, Age, Game, YearsPlaying) VALUES (?, ?, ?, ?,?)"
Upvotes: 4