.NETGURU
Duda Transacciones
Messages   Related Types
This message was discovered on ASPFriends.com 'aspnges' list.


Laura San Roman
Hola!!

    De nuevo tengo un problemilla esta vez con transacciones. ?Alguien
me podria ayudar?. Tengo el siguiente codigo:

            SqlConnection myConnection = new
SqlConnection("server=localhost;database=pubs;Trusted_Connection=yes");
            myConnection.Open();
            //Comienza la transaccion
            SqlTransaction myTrans =
myConnection.BeginTransaction();
            SqlCommand myCommand = new SqlCommand();
            myCommand.Transaction = myTrans;
            try
            {
                myCommand.CommandText = CadenaSQL;
                myCommand.ExecuteNonQuery();
                myCommand.CommandText = CadenaSQL1;
                myCommand.ExecuteNonQuery();
                myTrans.Commit();
            }
            catch(Exception e)
            {
                myTrans.Rollback();
            }
            finally
            {
                myConnection.Close();
            }

    CadenaSQL tiene un insert a la base de datos que funciona
perfectamente, pero cuando llega al metodo myCommand.ExecuteNonQuery()
siempre me sale por la excepcion con el mismo mensaje: La conexion no ha
sido inicializada. Llevo dandole vueltas y ya no veo nada ?alguien me puede
decir que estoy haciendo mal?

Gracias y un saludo

Reply to this message...
 
    
Luis Ruiz
abre la conexion

nombredetuconexion.open

antes de darle executenonquery

kike

--- Laura San Roman <Click here to reveal e-mail address>
wrote:
[Original message clipped]

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

Reply to this message...
 
    
Luis Ruiz
creo qute te falta asignarle la conexion a tu comando

myCommand.Connection = SqlCon

me equivoque vi que abristes la conexion

kike

--- Laura San Roman <Click here to reveal e-mail address>
wrote:
[Original message clipped]

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

Reply to this message...
 
    
Adrian Garcia
Probaste con:
....
            myCommand.ActiveConection = myConnection;
            myCommand.Transaction = myTrans;
try ....

Saludos

Adrian Garcia
Microsoft MVP [C#/ASP] - MCSD
NDSoft Filial Córdoba - Argentina
Click here to reveal e-mail address

----Original Message Follows----
From: Laura San Roman <Click here to reveal e-mail address>
Reply-To: "aspnges" <Click here to reveal e-mail address>
To: "aspnges" <Click here to reveal e-mail address>
Subject: [aspnges] Duda Transacciones
Date: Fri, 24 Aug 2001 11:52:25 +0100

Hola!!

    De nuevo tengo un problemilla esta vez con transacciones. ?Alguien
me podria ayudar?. Tengo el siguiente codigo:

            SqlConnection myConnection = new
SqlConnection("server=localhost;database=pubs;Trusted_Connection=yes");
            myConnection.Open();
            //Comienza la transaccion
            SqlTransaction myTrans =
myConnection.BeginTransaction();
            SqlCommand myCommand = new SqlCommand();
            myCommand.Transaction = myTrans;
            try
            {
                myCommand.CommandText = CadenaSQL;
                myCommand.ExecuteNonQuery();
                myCommand.CommandText = CadenaSQL1;
                myCommand.ExecuteNonQuery();
                myTrans.Commit();
            }
            catch(Exception e)
            {
                myTrans.Rollback();
            }
            finally
            {
                myConnection.Close();
            }

    CadenaSQL tiene un insert a la base de datos que funciona
perfectamente, pero cuando llega al metodo myCommand.ExecuteNonQuery()
siempre me sale por la excepcion con el mismo mensaje: La conexion no ha
sido inicializada. Llevo dandole vueltas y ya no veo nada ?alguien me puede
decir que estoy haciendo mal?

Gracias y un saludo

| [aspnges] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspnges.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

_________________________________________________________________
Descargue GRATUITAMENTE MSN Explorer en http://explorer.msn.es/intl.asp

Reply to this message...
 
    
Laura San Roman
Muchas gracias a todos.
Saludos

-----Original Message-----
From: Adrian Garcia [mailto:Click here to reveal e-mail address]
Sent: viernes, 24 de agosto de 2001 20:54
To: aspnges
Subject: [aspnges] Re: Duda Transacciones

Probaste con:
....
            myCommand.ActiveConection =3D myConnection;
            myCommand.Transaction =3D myTrans;
try ....

Saludos

Adrian Garcia
Microsoft MVP [C#/ASP] - MCSD
NDSoft Filial C=F3rdoba - Argentina
Click here to reveal e-mail address

----Original Message Follows----
From: Laura San Roman <Click here to reveal e-mail address>
Reply-To: "aspnges" <Click here to reveal e-mail address>
To: "aspnges" <Click here to reveal e-mail address>
Subject: [aspnges] Duda Transacciones
Date: Fri, 24 Aug 2001 11:52:25 +0100

Hola!!

    De nuevo tengo un problemilla esta vez con transacciones. ?Alguien
me podria ayudar?. Tengo el siguiente codigo:

            SqlConnection myConnection =3D new
SqlConnection("server=3Dlocalhost;database=3Dpubs;Trusted_Connection=3Dy=
es");
            myConnection.Open();
            //Comienza la transaccion
            SqlTransaction myTrans =3D
myConnection.BeginTransaction();
            SqlCommand myCommand =3D new SqlCommand();
            myCommand.Transaction =3D myTrans;
            try
            {
                myCommand.CommandText =3D CadenaSQL;
                myCommand.ExecuteNonQuery();
                myCommand.CommandText =3D CadenaSQL1;
                myCommand.ExecuteNonQuery();
                myTrans.Commit();
            }
            catch(Exception e)
            {
                myTrans.Rollback();
            }
            finally
            {
                myConnection.Close();
            }

    CadenaSQL tiene un insert a la base de datos que funciona
perfectamente, pero cuando llega al metodo myCommand.ExecuteNonQuery()
siempre me sale por la excepcion con el mismo mensaje: La conexion no =
ha
sido inicializada. Llevo dandole vueltas y ya no veo nada ?alguien me =
puede
decir que estoy haciendo mal?

Gracias y un saludo

| [aspnges] member Click here to reveal e-mail address =3D YOUR ID
| http://www.asplists.com/asplists/aspnges.asp =3D JOIN/QUIT
| http://www.asplists.com/search =3D SEARCH Archives

_________________________________________________________________
Descargue GRATUITAMENTE MSN Explorer en http://explorer.msn.es/intl.asp

| [aspnges] member Click here to reveal e-mail address =3D YOUR ID
| http://www.asplists.com/asplists/aspnges.asp =3D JOIN/QUIT
| http://www.asplists.com/search =3D SEARCH Archives

Reply to this message...
 
 
System.Data.SqlClient.SqlCommand
System.Data.SqlClient.SqlConnection
System.Data.SqlClient.SqlTransaction




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification