INSERT INTO with InsertParameters: Must declare the variable XXX
Hi
What's wrong with this code, i keep getting an error "Must declar the
variable [at] MyTitle"
Thanks
-----HTML CODE-----
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:Conn1%>"
InsertCommand="INSERT INTO Links(Title) VALUES ( [at] MyTitle)">
<InsertParameters>
<asp:ControlParameter PropertyName="text" ControlID="txtWebsiteTitle"
Name=" [at] MyTitle" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
<asp:TextBox text="XXXXXXXXXXXtitle from default" runat="server"
id="txtWebsiteTitle" />
<asp:Button id="btnLinkExchange" onclick="btnLinkExchange_click"
runat="server" Text="Submit Link" />
-----CODEBEHIND-----
protected void btnLinkExchange_click(object sender,
System.EventArgs e)
{
SqlDataSource1.Insert();
}
RE: INSERT INTO with InsertParameters: Must declare the variable XXX
Hi,
I dont see anything wrong with the code. Please refer to the link below for
inserting rows in database using SqlDatasource control.
http://msdn2.microsoft.com/en-us/library/system.web.ui.webco ntrols.sqldatasource.insert.aspx
Regards,
Manish
www.componentOne.com
"seanmatthewwalsh [at] hotmail.com" wrote:
> Hi
>
> What's wrong with this code, i keep getting an error "Must declar the
> variable [at] MyTitle"
>
> Thanks
>
> -----HTML CODE-----
> <asp:SqlDataSource ID="SqlDataSource1" runat="server"
> ConnectionString="<%$ ConnectionStrings:Conn1%>"
> InsertCommand="INSERT INTO Links(Title) VALUES ( [at] MyTitle)">
> <InsertParameters>
> <asp:ControlParameter PropertyName="text" ControlID="txtWebsiteTitle"
> Name=" [at] MyTitle" Type="String" />
> </InsertParameters>
> </asp:SqlDataSource>
> <asp:TextBox text="XXXXXXXXXXXtitle from default" runat="server"
> id="txtWebsiteTitle" />
> <asp:Button id="btnLinkExchange" onclick="btnLinkExchange_click"
> runat="server" Text="Submit Link" />
>
> -----CODEBEHIND-----
> protected void btnLinkExchange_click(object sender,
> System.EventArgs e)
> {
> SqlDataSource1.Insert();
> }
>