Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have class to return conetionstring

I use sqltransacton in main form

but when I whrite (The connecton is My class)

cann't open the conection !!!!!

Can you Help me?


Could you please post the code.

Share this answer
raheleh_es 2-Jul-11 5:23am    
public SqlConnection connnn() { SqlConnection co= new SqlConnection ( @"My conection"); return co; }//********* private void button1_Click(object sender, EventArgs e) { SqlTransaction sqltarac; co.connnn ().Open(); sqltarac = co.connnn ().BeginTransaction(); for (int i = 0; i < dataGridView1.Rows.Count - 1; i++) { new SqlCommand ("Coding Insert "), co.connn(),sqltarac ).ExecuteNonQuery () ; } if (falag == true) { sqltarac.Commit(); }else{ sqltarac.Rollback();co.connnn ().Close();}
[no name] 2-Jul-11 6:37am    
its not the complete code dear.put the "My conection" connection string .and you have to user SqlCommand class as well...
raheleh_es 2-Jul-11 8:52am    
I put it in my code but cann't open conention Plz Help Me
The main problem of your code is that it is not correct. Go to any msdn site which have already defined how you could use transaction. Then use it.

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900