- 最後登錄
- 2024-4-16
- 在線時間
- 0 小時
- 註冊時間
- 2010-8-2
- 閱讀權限
- 20
- 精華
- 0
- UID
- 8532024
- 帖子
- 454
- 積分
- 707 點
- 潛水值
- 25272 米
| 若新密碼無法使用,可能是數據未更新。請使用舊密碼看看。 本帖最後由 radenli 於 2013-6-24 12:47 PM 編輯
- ...
- using System.Data;
- using System.Data.SqlClient;
- ......
- private static string connStr ="Your SQL connection string list here"
- public static bool AddItem(var parametersHere)
- {
- bool result = false;
- SqlConnection sqlConn = new SqlConnection(connStr);
- string sqlInsertCmd="INSERT INTO tablename VALUES (values1,values2,..........)";
- SqlCommand sqlCmd = new SqlCommand(sqlInsertCmd,sqlConn);
- try
- {
- sqlConn.Open();
- result= sqlCmd.ExecuteNonQuery() != -1;
- }
- catch
- {
- // prevent the exception from propagating, but return false to
- // signal the error
- result = false;
- }
- finally {
- sqlConn.Close();
- }
複製代碼
a good source of SQL statement
...
|
|