hi all, i'm retreiving user input using textboxes and saving to a gridview. i'm getting this error and i dont know whats causing it.
<asp:SqlDataSourceID="SqlDataSource1"runat="server"InsertCommand="INSERT INTO test101(Surname,Names,Regno)VALUES (@.Surname, @.Names, @.Regno)"
ConnectionString="<%$ ConnectionStrings:engineeringConnectionString %>"ProviderName=System.Data.SqlClientConflictDetection="CompareAllValues">
<InsertParameters>
<asp:ControlParameterControlID="TextBox1"DefaultValue="TextBox1.Text"Name="Surname"
PropertyName="Text"Size="50"Type=Char/>
<asp:ControlParameterControlID="TextBox2"DefaultValue="TextBox2.Text"Name="Names"
PropertyName="Text"Size="50"Type=Char/>
<asp:ParameterDefaultValue="TextBox3.Text"Name="Regno"/>
</InsertParameters>
</asp:SqlDataSource>
<asp:GridViewID="GridView1"
runat="server"AutoGenerateColumns="False"AutoGenerateDeleteButton="True"DataKeyNames="ID"
AutoGenerateEditButton="True"AllowSorting="True"BackColor="LightGoldenrodYellow"BorderColor="Tan"BorderWidth="1px"CellPadding="2"ForeColor="Black"GridLines="None"PageSize="20"
Height="374px"EmptyDataText="null"DataSourceID=SqlDataSource1Visible="False">
<Columns>
<asp:BoundFieldDataField="ID"HeaderText="ID"InsertVisible="False"ReadOnly="True"
SortExpression="ID"/>
<asp:BoundFieldDataField="Surname"HeaderText="Surname"SortExpression="Surname"/>
<asp:BoundFieldDataField="Names"HeaderText="Names"SortExpression="Names"/>
<asp:BoundFieldDataField="Registration"HeaderText="Registration"SortExpression="Registration"/>
<asp:BoundFieldDataField="Grade"HeaderText="Grade"SortExpression="Grade"/>
</Columns>
</asp:GridView>
and the code behind is:
protectedvoid Page_Load(object sender,EventArgs e){
SqlConnection conn =newSqlConnection("Data Source=(local);Initial Catalog=engineering; Integrated Security=True");
conn.Open();
GridView1.DataBind();
conn.Close();
}
publicvoid login1_Click(object sender,EventArgs e)
{
SqlDataSource1.Insert();
Response.Write("you have successfully being added to the database");
can anyone help?!!!
Check out this link:http://vbcity.com/forums/topic.asp?tid=148073
Good luck.
No comments:
Post a Comment