SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2008
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem with Details View

    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

    Code:
    You tried to assign the Null value to a variable that is not a Variant data type.
    this is my code for the details view

    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>

  2. #2
    SitePoint Enthusiast
    Join Date
    Feb 2008
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does anyone know how this can be fixed or even where my problem is?

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2008
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think it could possibly be the parameters but I am not sure what is actually wrong with them!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •