Click here to Skip to main content
15,897,891 members
Home / Discussions / C#
   

C#

 
Questioninserting data SQLCommand C# - am I missing something? Pin
laziale20-Jun-08 4:18
laziale20-Jun-08 4:18 
AnswerRe: inserting data SQLCommand C# - am I missing something? Pin
User 665820-Jun-08 4:25
User 665820-Jun-08 4:25 
GeneralRe: inserting data SQLCommand C# - am I missing something? Pin
laziale20-Jun-08 4:32
laziale20-Jun-08 4:32 
GeneralRe: inserting data SQLCommand C# - am I missing something? Pin
User 665820-Jun-08 4:36
User 665820-Jun-08 4:36 
GeneralRe: inserting data SQLCommand C# - am I missing something? Pin
laziale20-Jun-08 4:39
laziale20-Jun-08 4:39 
GeneralRe: inserting data SQLCommand C# - am I missing something? Pin
User 665820-Jun-08 4:39
User 665820-Jun-08 4:39 
GeneralRe: inserting data SQLCommand C# - am I missing something? Pin
laziale20-Jun-08 4:43
laziale20-Jun-08 4:43 
GeneralRe: inserting data SQLCommand C# - am I missing something? Pin
laziale20-Jun-08 5:01
laziale20-Jun-08 5:01 
I use it the informations what you provide me, and it gives me error after the ExecuteNonQuery line, here is how I tried to solve:

SqlTransaction transaction;
transaction = conn.BeginTransaction("BeginTransaction");
SqlCommand command = conn.CreateCommand();
try
{

command.CommandText = query;
command.ExecuteNonQuery();
transaction.Commit();
}
catch (Exception ex)
{
throw new Exception(ex.ToString(), ex);
}
finally
{
conn.Close();
}


This is the exception:
System.InvalidOperationException: ExecuteNonQuery requires the command to have a transaction when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized.
GeneralRe: inserting data SQLCommand C# - am I missing something? Pin
User 665820-Jun-08 5:11
User 665820-Jun-08 5:11 
AnswerRe: inserting data SQLCommand C# - am I missing something? Pin
leppie20-Jun-08 4:29
leppie20-Jun-08 4:29 
GeneralRe: inserting data SQLCommand C# - am I missing something? Pin
laziale20-Jun-08 4:31
laziale20-Jun-08 4:31 
AnswerRe: inserting data SQLCommand C# - am I missing something? Pin
User 665820-Jun-08 4:42
User 665820-Jun-08 4:42 
AnswerRe: inserting data SQLCommand C# - am I missing something? Pin
Pete O'Hanlon20-Jun-08 5:01
mvePete O'Hanlon20-Jun-08 5:01 
GeneralRe: inserting data SQLCommand C# - am I missing something? Pin
laziale20-Jun-08 5:02
laziale20-Jun-08 5:02 
GeneralRe: inserting data SQLCommand C# - am I missing something? Pin
User 665820-Jun-08 5:12
User 665820-Jun-08 5:12 
QuestionProblem executing the Order of Forms..............pls help. Pin
Verghese20-Jun-08 4:11
Verghese20-Jun-08 4:11 
AnswerRe: Problem executing the Order of Forms..............pls help. Pin
User 665820-Jun-08 4:16
User 665820-Jun-08 4:16 
GeneralRe: Problem executing the Order of Forms..............pls help. Pin
Verghese20-Jun-08 4:35
Verghese20-Jun-08 4:35 
AnswerRe: Problem executing the Order of Forms..............pls help. Pin
Abhijit Jana20-Jun-08 4:17
professionalAbhijit Jana20-Jun-08 4:17 
Questionfilesystemwatcher Pin
arkiboys20-Jun-08 3:56
arkiboys20-Jun-08 3:56 
AnswerRe: filesystemwatcher Pin
Abhijit Jana20-Jun-08 4:08
professionalAbhijit Jana20-Jun-08 4:08 
GeneralRe: filesystemwatcher Pin
arkiboys20-Jun-08 4:17
arkiboys20-Jun-08 4:17 
GeneralRe: filesystemwatcher Pin
Abhijit Jana20-Jun-08 4:20
professionalAbhijit Jana20-Jun-08 4:20 
GeneralRe: filesystemwatcher Pin
arkiboys20-Jun-08 4:26
arkiboys20-Jun-08 4:26 
GeneralRe: filesystemwatcher Pin
arkiboys20-Jun-08 4:30
arkiboys20-Jun-08 4:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.