|
 |
|
checkBox ข้อมูลไม่เข้าในฐานข้อมูล รบกวนสอบถามว่า ต้องทำยังไงค่ะ ถึงให้ข้อมูลเข้าอะค่ะ |
|
 |
|
|
 |
 |
|
Code (C#)
private void button1_Click(object sender, EventArgs e)
{
string Chbox1 = "";
string Chbox2 = "";
string Chbox3 = "";
if (this.checkBox1.Checked==true)
{
Chbox1 = "True";
}
else if (this.checkBox1.Checked == false)
{
Chbox1 = "false";
}
if (this.checkBox2.Checked == true)
{
Chbox2 = "True";
}
else if (this.checkBox2.Checked == false)
{
Chbox2 = "false";
}
if (this.checkBox3.Checked == true)
{
Chbox3 = "True";
}
else if (this.checkBox3.Checked == false)
{
Chbox3 = "false";
}
MessageBox.Show(Chbox1, "ผลสำรวจของคุณ", MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBox.Show(Chbox2, "ผลสำรวจของคุณ", MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBox.Show(Chbox3, "ผลสำรวจของคุณ", MessageBoxButtons.OK, MessageBoxIcon.Information);
SqlCommand cmd = new SqlCommand("INSERT INTO Document (Doc_01, Doc_02, Doc_03) VALUES ('" + Chbox1 + "','" + @Chbox2 + "','" + @Chbox3 + "')", cn);
cmd.Parameters.AddWithValue("@Chbox1", checkBox1.Text);
cmd.Parameters.AddWithValue("@Chbox2", checkBox2.Text);
cmd.Parameters.AddWithValue("@Chbox3", checkBox3.Text);
}
ปัญหาคือ ข้อมูลไม่เข้าในฐานข้อมูล รบกวนสอบถามว่า ต้องทำยังไงค่ะ ถึงให้ข้อมูลเข้าอะค่ะ
ขอบคุณนะค่ะ...
Tag : .NET, C#, VS 2012 (.NET 4.x)

|
|
 |
 |
 |
 |
Date :
2012-08-15 01:04:30 |
By :
nameme18 |
View :
1008 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มี Error หรือเปล่าครับ ตรง ExecuteNonQuery()
|
 |
 |
 |
 |
Date :
2012-08-15 06:20:42 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่มีค่ะ...คือหนู run แล้ว..ค่า true กับ false มีแล้วนะค่ะ..แต่ยังงงอยู่ว่าทำไมไม่เข้าฐานข้อมูลอะค่ะ..รบกวนดด้วยนะค่ะ พี่
|
 |
 |
 |
 |
Date :
2012-08-15 09:25:12 |
By :
nameme18 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|