|
|
|
อยากทราบวิธีการส่งค่าลง sql โดยใช้ ภาษา asp.net ครับ |
|
|
|
|
|
|
|
Debug ช่วยได้ครับ โพสแค่ปัญหา แต่ไม่ลงรายละเอียดช่วยได้ยากหน่อยครับ
|
|
|
|
|
Date :
2010-08-05 06:35:35 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (C#)
using System;
using System.Data;
using System.Configuration;
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.Web.Configuration;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
private string strConn, strSql;
SqlCommand cmd;
SqlConnection conn;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void bt_ok_Click(object sender, EventArgs e)
{
strConn = WebConfigurationManager.ConnectionStrings["System sales CCTV online area in Bangkok"].ConnectionString;
conn = new SqlConnection(strConn);
conn.Open();
cmd = new SqlCommand();
strSql = "INSERT INTO [member]([Mem_usename],[Mem_password],[Mem_question],[Mem_answer],[Mem_fname],[Mem_lname],[Mem_card],[Mem_birthday],[Mem_address],[Mem_District],[Mem_province],[Mem_zipcode],[Mem_tel],[Mem_email]) VALUES(@Mem_usename,@Mem_password,@Mem_question,@Mem_answer,@Mem_fname,@Mem_lname,@Mem_card,@Mem_birthday,@Mem_sex,@Mem_address,@Mem_District,@Mem_province,@Mem_zipcode,@Mem_tel,@Mem_email)";
cmd.Parameters.Add("@Mem_usename", SqlDbType.VarChar).Value = TextBox3.Text.Trim();
cmd.Parameters.Add("@Mem_password", SqlDbType.VarChar).Value = TextBox4.Text.Trim();
cmd.Parameters.Add("@Mem_email", SqlDbType.VarChar).Value = TextBox6.Text.Trim();
cmd.Parameters.Add("@Mem_question", SqlDbType.VarChar).Value = TextBox7.Text.Trim();
cmd.Parameters.Add("@Mem_answer", SqlDbType.VarChar).Value = TextBox8.Text.Trim();
cmd.Parameters.Add("@Mem_fname", SqlDbType.VarChar).Value = TextBox9.Text.Trim();
cmd.Parameters.Add("@Mem_lname", SqlDbType.VarChar).Value = TextBox10.Text.Trim();
cmd.Parameters.Add("@Mem_birthday", SqlDbType.VarChar).Value = TextBox11.Text.Trim();
cmd.Parameters.Add("@Mem_card", SqlDbType.VarChar).Value = TextBox12.Text.Trim();
cmd.Parameters.Add("@Mem_address", SqlDbType.VarChar).Value = TextBox13.Text.Trim();
cmd.Parameters.Add("@Mem_District", SqlDbType.VarChar).Value = TextBox14.Text.Trim();
cmd.Parameters.Add("@Mem_province", SqlDbType.VarChar).Value = TextBox15.Text.Trim();
cmd.Parameters.Add("@Mem_zipcode", SqlDbType.VarChar).Value = TextBox16.Text.Trim();
cmd.Parameters.Add("@Mem_tel", SqlDbType.VarChar).Value = TextBox17.Text.Trim();
cmd.CommandText = strSql;
cmd.CommandType = CommandType.Text;
cmd.Connection = conn;
// int x = cmd.ExecuteNonQuery();
// txtName.Text = "";
// txtlastName.Text = "";
// TextBox1.Text = "";
}
protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
{
}
protected void TextBox3_TextChanged(object sender, EventArgs e)
{
}
}
|
|
|
|
|
Date :
2010-08-05 12:30:00 |
By :
enginnova |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// int x = cmd.ExecuteNonQuery();
Remark ไว้ทำไมครับ
|
|
|
|
|
Date :
2010-08-05 12:41:25 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
^
^
^
เอาออกแล้วครับพี่ใช้ได้เลย
เส้นผมบังภูเขาแท้ๆๆ
ขอบคุณมากครับ
|
|
|
|
|
Date :
2010-08-06 00:47:02 |
By :
enginnova |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|