Hey,
I am trying to insert data to a database via the inserting fuction in the details view but i seem to get this error
this is my code for the details viewCode:You tried to assign the Null value to a variable that is not a Variant data type.
Code:<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="348px" AllowPaging="True" AutoGenerateRows="False" CssClass="input" DataKeyNames="REG No,121" DataSourceID="AccessDataSource1"> <Fields> <asp:BoundField DataField="MAKE" HeaderText="Make" SortExpression="MAKE" /> <asp:BoundField DataField="MODEL" HeaderText="Model" SortExpression="MODEL" /> <asp:BoundField DataField="COLOUR" HeaderText="Colour" SortExpression="COLOUR" /> <asp:BoundField DataField="REG No" HeaderText="Reg Number" ReadOnly="True" SortExpression="REG No" /> <asp:BoundField DataField="D O R" HeaderText="Date of Registration" SortExpression="D O R" /> <asp:BoundField DataField="PRICE" HeaderText="Price" SortExpression="PRICE" /> <asp:BoundField DataField="MILEAGE" HeaderText="Mileage" SortExpression="MILEAGE" /> <asp:BoundField DataField="PICTURE" HeaderText="Picture" SortExpression="PICTURE" /> <asp:BoundField DataField="121" HeaderText="ID Number" InsertVisible="False" ReadOnly="True" SortExpression="121" /> <asp:CommandField ShowEditButton="True" ShowInsertButton="True" /> </Fields> </asp:DetailsView> <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/Datastore.mdb" DeleteCommand="DELETE FROM STOCKLIST" InsertCommand="INSERT INTO STOCKLIST([121], [REG No], COLOUR, MODEL, MAKE, [D O R], PRICE, MILEAGE, PICTURE) VALUES (@ID,@Reg_No,@Colour,@Model,@Make,@D_O_R,@Price,@Mileage,@Picture)" SelectCommand="SELECT MAKE, MODEL, COLOUR, [REG No], [D O R], PRICE, MILEAGE, PICTURE, [121] FROM STOCKLIST" UpdateCommand="UPDATE STOCKLIST SET [121] = @ID, MAKE = @Make, MODEL = @Model, COLOUR = @Colour, [REG No] = @Reg_No, [D O R] = @D_O_R, PRICE = @Price, MILEAGE = @Mileage, PICTURE = @Picture"> <InsertParameters> <asp:Parameter Name="@ID" /> <asp:Parameter Name="@Make" /> <asp:Parameter Name="@Model" /> <asp:Parameter Name="@Colour" /> <asp:Parameter Name="@Reg_No" /> <asp:Parameter Name="@D_O_R" /> <asp:Parameter Name="@Price" /> <asp:Parameter Name="@Mileage" /> <asp:Parameter Name="@Picture" /> </InsertParameters> </asp:AccessDataSource>




Bookmarks