いずれかが、私はADO.NETを使用して、このプログラムでエラーを識別するのに役立ちます...私のADO.NETコードで何が問題になっていますか?
コード:
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Transactions; // the code is showing an error in this line
class Program
{
static void Main(string[] args)
{
try
{
string connectString = "Initial Catalog=AdventureWorks;
Data Source=SQLSERVER01;
User id =user;password=password";
SqlConnection con = new SqlConnection();
con.ConnectionString = connectString;
con.Open();
SqlTransaction tr = null;
tr = con.BeginTransaction();
SqlCommand cmd = new SqlCommand("INSERT INTO sunny1(name, id, city, phone, pincode) VALUES ('sandy', 01441, 'abc', 'phone', 122001)", con, tr);
cmd.ExecuteNonQuery();
tr.Commit();
Console.WriteLine("transaction completed ");
}
catch (SqlException e)
{
tr.Rollback();
Console.WriteLine("teansaction not completed " + e.Message);
}
catch (System.Exception ex)
{
Console.WriteLine("system error " + ex.Message);
}
finally
{
cn.Close();
}
Console.ReadLine();
}
}
コードもいくつか不足しているアセンブリに関連したエラーメッセージが表示されます。
あなたがのために、任意の特定の理由はあります – marcgg
任意の有用な答えを得ることはありません、他のより詳細な情報を与える必要がありますかタイトルにすべての帽子を書く? – hlovdal