|
 |
|
INSERT ข้อมูลลงใน ACCESS ไม่ได้ รบกวนทีคร๊าบบบ T^T [Win app C#] |
|
 |
|
|
 |
 |
|
Code (C#)
private void bntadd_Click(object sender, EventArgs e)
{
OleDbCommand objCmd = new OleDbCommand();
String strConnString,strSQL;
OleDbConnection objConn;
DateTime dt = DateTime.Now;
string mmAdd1 = DateTime.Now.AddDays(0).ToString("dd") + "/" + dt.ToString("MM", new System.Globalization.CultureInfo("th-TH")) + "/" + dt.ToString("yyyy", new System.Globalization.CultureInfo("th-TH"));
string librarian="xxxxxxxxxxxxxxx";
strConnString = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=C:\\Catalog.mdb";
strSQL = "INSERT INTO Table_Catalog (ID,Name,Author,Company,Year,Price,Amount,By,Date)" + " VALUES " + "('" + txtid.Text + "','" + txtname.Text + "','" + txtauther.Text + "','" + txtcompany.Text + "','" + txtyear.Text + "'," + txtprice.Text + "," + txtamount.Text + ",'" + librarian + "','" + mmAdd1 + "')";
objConn = new OleDbConnection(strConnString);
if (objConn.State == ConnectionState.Open)
{
objConn.Close();
}
objConn.ConnectionString = strConnString;
objConn.Open();
objCmd.Connection = objConn;
objCmd.CommandText = strSQL;
objCmd.CommandType = CommandType.Text;
try{
objCmd.ExecuteNonQuery();
MessageBox.Show("Record Inserted");
}
catch (Exception ex)
{
// Error เพราะขึ้น MessageBox.Show(ex.ToString());
MessageBox.Show(ex.ToString());
}
objCmd = null;
objConn.Close();
objConn = null;
}
รบกวนช่วยดูให้ทีครับว่า ทำไมผมถึง INSERT ไฟล์ลงใน DB ACCESS ไม่ได้
ใช้เวลานานมาก มันอาจจะเกี่ยวกับ Permission อะไรหรือเปล่า ผมก็ไม่ทราบครับ
รบกวนผู้รู้ตอบทีครับ

รูป ex.ToString() ครับ
Tag : .NET, Ms Access, Win (Windows App), C#

|
ประวัติการแก้ไข 2012-09-17 03:15:03 2012-09-17 03:17:16 2012-09-17 03:21:00
|
 |
 |
 |
 |
Date :
2012-09-17 03:13:51 |
By :
pornanan20 |
View :
1035 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แก้แล้วก้อยังขึ้นเหมือนเดิมเรยครับ จนปัญญาจิงๆ 
|
 |
 |
 |
 |
Date :
2012-09-17 16:50:30 |
By :
pornanan20 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|