我有这个代码:
protected void Page_Load(object sender, EventArgs e)
{
SqlDataSource4.SelectParameters["zadavatel"].DefaultValue = this.Page.User.Identity.Name;
}
标记:
<InsertParameters>
<asp:Parameter Name="zadavatel" Type="String" />
</InsertParameters>
<asp:SqlDataSource ID="SqlDataSource4" runat="server"
ConnectionString="<%$ ConnectionStrings:fotbalConnectionString %>"
DeleteCommand="DELETE Diskuze WHERE Id_Diskuze=@Id_Diskuze"
SelectCommand="SELECT * FROM [Diskuze] WHERE ([Id_Zapasu] = @Id_Zapasu) ORDER BY [Datum_Vytvoreni] ASC"
InsertCommand="INSERT INTO Diskuze (Autor, TextD, Ip_Adresa, Id_Zapasu) VALUES (@zadavatel, @TextD, '127.0.0.1', @Id_zapasu)">
我想将参数插入zadavatel
Autor ...但我收到此错误:
System.NullReferenceException: Odkaz na objekt není nastaven na instanci objektu。(你调用的对象是空的。)
我不知道问题出在哪里:/