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 "@vfirstnam e" 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="_Defa ult" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html>
<Script runat="server">
Private Sub Insertmember(By Val Source As Object, ByVal e As EventArgs)
SqlDataSource1. Insert()
End Sub
</Script>
<body>
<form id="form1" runat="server">
<asp:SqlDataSou rce
ID="SqlDataSour ce1"
runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:ConnectionSt ring %>" ProviderName="< %$ ConnectionStrin gs:ConnectionSt ring.ProviderNa me %>"
InsertCommand = "Insert into memberlogin (cfirstname,cla stname) values (@vcfistname,@v clastname)" >
<InsertParamete rs>
<asp:FormParame ter Name="@vcfirstn ame" FormField="fnam e" />
<asp:FormParame ter Name="@vclastna me" FormField="lnam e" />
</InsertParameter s>
</asp:SqlDataSour ce>
<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:RequiredFi eldValidator
id="RequiredFie ldValidator1"
runat="server"
ControlToValida te="fname"
Display="Static "
ErrorMessage="P lease 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:RequiredFi eldValidator
id="RequiredFie ldValidator2"
runat="server"
ControlToValida te="lname"
Display="Static "
ErrorMessage="P lease enter a Last Name." />
</td>
</tr>
<tr>
<td colspan=2>
<asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Insert member"/> </td>
</tr>
</table>
</body>
</html>
--------------------------------------------------------------------------------------------------------------
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 "@vfirstnam e" 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="_Defa ult" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html>
<Script runat="server">
Private Sub Insertmember(By Val Source As Object, ByVal e As EventArgs)
SqlDataSource1. Insert()
End Sub
</Script>
<body>
<form id="form1" runat="server">
<asp:SqlDataSou rce
ID="SqlDataSour ce1"
runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:ConnectionSt ring %>" ProviderName="< %$ ConnectionStrin gs:ConnectionSt ring.ProviderNa me %>"
InsertCommand = "Insert into memberlogin (cfirstname,cla stname) values (@vcfistname,@v clastname)" >
<InsertParamete rs>
<asp:FormParame ter Name="@vcfirstn ame" FormField="fnam e" />
<asp:FormParame ter Name="@vclastna me" FormField="lnam e" />
</InsertParameter s>
</asp:SqlDataSour ce>
<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:RequiredFi eldValidator
id="RequiredFie ldValidator1"
runat="server"
ControlToValida te="fname"
Display="Static "
ErrorMessage="P lease 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:RequiredFi eldValidator
id="RequiredFie ldValidator2"
runat="server"
ControlToValida te="lname"
Display="Static "
ErrorMessage="P lease enter a Last Name." />
</td>
</tr>
<tr>
<td colspan=2>
<asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Insert member"/> </td>
</tr>
</table>
</body>
</html>
--------------------------------------------------------------------------------------------------------------
Comment