谁有操作SQL2000数据库的添加、删除、更新的源码。回复有分,谢了!!

Yock 2004-06-30 03:20:24
谁有操作SQL2000数据库,添加、删除、更新的源码。
...全文
148 11 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
feifanyuge 2004-06-30
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/topic/3134/3134358.xml?temp=.5690424

帮忙看看!大哥们!
xhn1 2004-06-30
  • 打赏
  • 举报
回复
到处都有啊 随便搜索一下就行了
aidoudou 2004-06-30
  • 打赏
  • 举报
回复
来得晚不晚呀,我也在写这个没什么新意的东西
guoyangc 2004-06-30
  • 打赏
  • 举报
回复
//删除的源码

bool DeleteDB(SqlConnection sqlConnection)
{
SqlTransaction bookTransaction = null;

try
{
// Start a local transaction
bookTransaction = sqlConnection.BeginTransaction();

string deleteSQL = "DELETE FROM test WHERE testID=1";

SqlCommand deleteCMD = new SqlCommand(deleteSQL, sqlConnection);
deleteCMD.Transaction = bookTransaction;

int delRow = deleteCMD.ExecuteNonQuery();

if (delRow == 0)
{
bookTransaction.Rollback();

return false;
}
bookTransaction.Commit();

return true;
}
catch
{
bookTransaction.Rollback();
return false;
}
}

//更新的源码
bool UpdateDB(SqlConnection sqlConnection)
{
SqlTransaction bookTransaction = null;

try
{
// Start a local transaction
bookTransaction = sqlConnection.BeginTransaction();

string updateSQL = "Update test set test1 = '2' WHERE testID=1";

SqlCommand updateCMD = new SqlCommand(deleteSQL, sqlConnection);
updateCMD.Transaction = bookTransaction;

int delRow = updateCMD.ExecuteNonQuery();

if (delRow == 0)
{
bookTransaction.Rollback();

return false;
}
bookTransaction.Commit();

return true;
}
catch
{
bookTransaction.Rollback();
return false;
}
}
sea026 2004-06-30
  • 打赏
  • 举报
回复
Microsoft 101 sample 有n多

http://www.microsoft.com/downloads/details.aspx?FamilyID=08e3d5f8-033d-420b-a3b1-3074505c03f3&DisplayLang=en
guoyangc 2004-06-30
  • 打赏
  • 举报
回复
//添加的源码

bool InsertDB(SqlConnection sqlConnection)
{
SqlTransaction bookTransaction = null;

try
{
// Start a local transaction
bookTransaction = sqlConnection.BeginTransaction();

string insertSQL = "Insert into Test(test1, test2) values('1', '2')";

SqlCommand insertCMD = new SqlCommand(insertSQL, sqlConnection);
insertCMD.Transaction = bookTransaction;

int insRow = insertCMD.ExecuteNonQuery();

if (insRow == 0)
{
bookTransaction.Rollback();

return false; //失败
}
bookTransaction.Commit();

return true;//成功
}
catch
{
return false;
}
}
yemao20 2004-06-30
  • 打赏
  • 举报
回复
UP
LiJoe 2004-06-30
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/topic/2971/2971408.xml?temp=.9550135
小贵子88 2004-06-30
  • 打赏
  • 举报
回复
我也顶
Yock 2004-06-30
  • 打赏
  • 举报
回复
等等吧小子
skyhill13 2004-06-30
  • 打赏
  • 举报
回复
我没有,但是我顶!给分可以了吧,我是第一个顶的哦

111,097

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧