Hi,
I've been trying to send my parameters from textbox to sqldatasource but i always get "Must declare the scalar variable" message.
I tried several ways and this is what i got.
At button:
protected void Button1_Click(object sender, EventArgs e)
{
SqlDataSource2.InsertParameters.Add("@xlnam", xlnam);
SqlDataSource2.InsertParameters.Add("@xfnam", xfnam);
SqlDataSource2.InsertParameters.Add("@xstreet", xstreet);
SqlDataSource2.Insert();
}
at aspx:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />
<br />
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<br />
<asp:Label ID="Label2" runat="server" Text="Label" Width="568px"></asp:Label><br />
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:Connectionspainlink %>"
InsertCommand="INSERT INTO members(lnam, fnam, street1) VALUES (@xlnam,@xfnam,@xstreet)"
ProviderName="<%$ ConnectionStrings:Connectionspainlink.ProviderName %>" SelectCommand="SELECT id, fnam, lnam, street1 FROM members">
<InsertParameters>
<asp:ControlParameter ControlID="TextBox1" Name="xlnam" DefaultValue="@xlnam" PropertyName="Text" />
<asp:ControlParameter ControlID="TextBox2" Name="xfnam" DefaultValue="@xfnam" PropertyName="Text" />
<asp:ControlParameter ControlID="TextBox3" Name="xstreet" DefaultValue="@xstreet" PropertyName="Text" />
</InsertParameters>
</asp:SqlDataSource>
<asp:Button ID="Button1" runat="server" Text="Button" PostBackUrl="~/test.aspx" OnClick="Button1_Click" />
I cant use a form way cause i already got a form at MasterPage for the menu.
Can please some one help me to solve this? its dryving me crazy.
I've been trying to send my parameters from textbox to sqldatasource but i always get "Must declare the scalar variable" message.
I tried several ways and this is what i got.
At button:
protected void Button1_Click(object sender, EventArgs e)
{
SqlDataSource2.InsertParameters.Add("@xlnam", xlnam);
SqlDataSource2.InsertParameters.Add("@xfnam", xfnam);
SqlDataSource2.InsertParameters.Add("@xstreet", xstreet);
SqlDataSource2.Insert();
}
at aspx:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />
<br />
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<br />
<asp:Label ID="Label2" runat="server" Text="Label" Width="568px"></asp:Label><br />
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:Connectionspainlink %>"
InsertCommand="INSERT INTO members(lnam, fnam, street1) VALUES (@xlnam,@xfnam,@xstreet)"
ProviderName="<%$ ConnectionStrings:Connectionspainlink.ProviderName %>" SelectCommand="SELECT id, fnam, lnam, street1 FROM members">
<InsertParameters>
<asp:ControlParameter ControlID="TextBox1" Name="xlnam" DefaultValue="@xlnam" PropertyName="Text" />
<asp:ControlParameter ControlID="TextBox2" Name="xfnam" DefaultValue="@xfnam" PropertyName="Text" />
<asp:ControlParameter ControlID="TextBox3" Name="xstreet" DefaultValue="@xstreet" PropertyName="Text" />
</InsertParameters>
</asp:SqlDataSource>
<asp:Button ID="Button1" runat="server" Text="Button" PostBackUrl="~/test.aspx" OnClick="Button1_Click" />
I cant use a form way cause i already got a form at MasterPage for the menu.
Can please some one help me to solve this? its dryving me crazy.