Inserting ASP.NET form data to SQL table

Joined
Mar 14, 2008
Messages
2
Reaction score
0
Hi, i've been searching and searching through various tutorials but unable to find out a difinitive way of adding form data upon submission to a SQL 2005 table, there seems to be so many different ways and i'm quite confused


So if someone could just get me started i think i would be able to figure out the rest.


Default.aspx source:


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp: panel runat ="server" ID="panel1">
<asp:label ID="label1" runat="server" Font-Size="XX-Large">Data Entry Form</asp:label><br />
Name : <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
<asp:Button ID="Button1" runat="server" Text="Insert Record" />
</asp: panel>
</div>
</form>
</body>
</html>


Default.aspx.cs code:


using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Default : System.Web.UI.Page

{

protected void Button1_Click(object sender, EventArgs e)

{

What do I put in here??

}

}



Code from web.config file:


<connectionStrings>

<clear />

<add name="BetaSQL" connectionString="Data Source=IP Address; Initial Catalog=Company Name; Persist Security Info=True; User ID= UserID ; Password= Password"

providerName="System.Data.SqlClient" />

</connectionStrings>


Table on the BetaSQL that i could like to write the form data to:


Table name: KF_T

Table definition:

Column Name - Name
Data Type - text
Allow Nulls - unchecked


Eventually I will be putting in other text boxs and check boxes which i would like it to write to the same table on the SQL Server so if there was an example of how to do that it would be extremly appreciated


I hope this makes sense


Thankyou
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top