English 中文(简体)
• 在伙伴关系中发现错误。 NET
原标题:Getting an error in ASP.NET

我正在发现这一错误。

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>

我已经结束,我不能让它工作。 谁能帮助我? 感谢。

当我试图删除“Id”中的“参数”时,它有不同的错误。

最佳回答

Remove the IDInsertPara amount:

<asp:Parameter Name="ID" Type="Int32" />

更改<代码>InsertCommand:

InsertCommand="INSERT INTO [Table1] (Name, ScreenName, Age, Game, YearsPlaying) VALUES (?, ?, ?, ?,?)" 

解决“你试图将Null值分配给一个并非变式数据类型的变量”。 例外情况

问题回答

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!





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签