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




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com