string sConnect;
sConnect = string.Format("Server={0};Database={1};{2}",
"localhost",
"Sales",
"Integrated Security=SSPI"); //id=sa;pwd=????
dbConn = new SQL.SqlConnection(sConnect);
dbConn.Open();
//parameter begin
sql = "Select * From Customers Where CID=@CID Order By LastName Asc, FirstName Asc;";
SQL.SqlCommand dbCmd;
dbCmd = new SQL.SqlCommand(sql, dbConn);
dbCmd.Parameters.Add("@CID", SqlDbType.BigInt);
dbCmd.Parameters[0].Value = 1;
//parameter end
*/
/*
//procedure begin
SQL.SqlCommand dbCmd =dbConn.CreateCommand();
dbCmd.CommandText = "GetCustomer";
dbCmd.CommandType = CommandType.StoredProcedure;
dbCmd.Parameters.Add("@CID", SqlDbType.BigInt);
dbCmd.Parameters[0].Value = 1;
//precedure end
*/
//Transaction
SQL.SqlTransaction txn = dbConn.BeginTransaction();
string strSQL = "INSERT INTO Customers VALUES(100,'Hui','Yu',1000000,1000000,'01-Jan-2005','money')";
SQL.SqlCommand dbCmd;
dbCmd = new SQL.SqlCommand(strSQL, dbConn,txn);
int intRecord = dbCmd.ExecuteNonQuery();
if(intRecord ==1)
{
SWF.MessageBox.Show( "Update Successful");
txn.Commit();
}
else
{
SWF.MessageBox.Show( "Update Failed");
txn.Rollback();
}
/*
}