如何对数据库进行不同的操作? [英] How do different operation on database?

查看:58
本文介绍了如何对数据库进行不同的操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在不同的地方对数据库执行不同的命令文本,如果其中一个操作没有完成回滚另一个命令

i want do differnt command text on database in different place , if one of this operation not complete rollback another command

推荐答案

你需要[...]动词,否则,没有人能够提出你的问题。如果您的帖子中缺少部分或全部动词,则不能形成一个格式正确的问题。

[...]关于动词,请[...]这篇文章:http://en.wikipedia.org/wiki/Verb [ ^ ]。



然而,即使使用正确的动词,我也怀疑我能否明白这个问题。







请参阅:http://msdn.microsoft.com/en-us/library/777e5ebh.aspx [ ^ ]。



-SA
You need to […] verbs, otherwise no one will be able to […] your questions. If some or all of the verbs are missing from your post, it cannot […] a well-formed question.
To […] about verbs, please […] this article: http://en.wikipedia.org/wiki/Verb[^].

However, even with proper use verbs, I doubt I can understand the question.



Please see: http://msdn.microsoft.com/en-us/library/777e5ebh.aspx[^].

—SA


如何在c中使用交易的示例



Example on how to use transactions in c#

using (SqlConnection Conn = new SqlConnection(_ConnectionString))
{
    try
    {
        Conn.Open();
        SqlTransaction Trans = Conn.BeginTransaction();

        try 
        {
            using (SqlCommand Com = new SqlCommand(ComText, Conn))
            {
                /* DB work */
            }
        }
        catch (Exception TransEx)
        {
            Trans.Rollback();
            return -1;
        }
    }
    catch (Exception Ex)
    {
        return -1;
    }
}


这篇关于如何对数据库进行不同的操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆