Hi this is nidhi from india,
Since last 2 days i am facing a problem in asp.net code. The data base connection is done correctly as i can select the data from the database. But i can not insert the data to sql server 2005 .
A error message occurs saying "@vfirstname" is not declared. I donot understand where do i declare the parameter and how? How do i insert data using stored procedure? Please guide me as early as possible.
Do write the code that makes easy to understand. please
----------------------------------------------------------------------------------------------------------------
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="login.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<Script runat="server">
Private Sub Insertmember(ByVal Source As Object, ByVal e As EventArgs)
SqlDataSource1.Insert()
End Sub
</Script>
<body>
<form id="form1" runat="server">
<asp:SqlDataSource
ID="SqlDataSource1"
runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>" ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>"
InsertCommand = "Insert into memberlogin (cfirstname,clastname) values (@vcfistname,@vclastname)" >
<InsertParameters>
<asp:FormParameter Name="@vcfirstname" FormField="fname" />
<asp:FormParameter Name="@vclastname" FormField="lname" />
</InsertParameters>
</asp:SqlDataSource>
<table border="0" width="742" cellspacing="0" cellpadding="0" id="table1">
<tr>
<td style="width:50%">First Name:</td>
<td style="width:50%">
<asp:TextBox ID="fname" runat="server" > </asp:TextBox>
<asp:RequiredFieldValidator
id="RequiredFieldValidator1"
runat="server"
ControlToValidate="fname"
Display="Static"
ErrorMessage="Please enter a First Name." /> </td>
</tr>
</tr>
<tr>
<td style="width:50%">Last Name:</td>
<td style="width:50%">
<asp:TextBox ID="lname" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator
id="RequiredFieldValidator2"
runat="server"
ControlToValidate="lname"
Display="Static"
ErrorMessage="Please enter a Last Name." />
</td>
</tr>
<tr>
<td colspan=2>
<asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Insertmember"/> </td>
</tr>
</table>
</body>
</html>
--------------------------------------------------------------------------------------------------------------