Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / November 2004

Tip: Looking for answers? Try searching our database.

Database Transactions

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Merline Martina - 23 Nov 2004 06:49 GMT
Can anyone tell me how to work with database transactions in a web service.
Can anyone please give me a sample code.
Signature

Cool!!
Merline

John Paul. A - 23 Nov 2004 06:59 GMT
Dear Merline Martina,
Here is a sample code which explains about the database transactions in a
web service.

[Web Method]
public string adduser( string UserName, string UserPassword)
{
    string uname,upassword;
    uname=UserNmae;
    upassword=userPassword;
    string mycon=”Intial Catalog=test;Data Source= johnpaul\DBTEST; Integrated
security =SSPI”;

    //declare a sql connection by building a object named myconnection
    SqlConnection mysqlConnection =new SqlConnection(mycon);
    // declare sql command by using a object named mycommand
    SqlCommand mysqlCommand = new SqlCommand();
    // using sql transaction class
    SqlTransaction myTrans;

    // Open the connection.
    mysqlConnection.Open();
    // Assign the connection property.
    mysqlCommand.Connection = mysqlConnection;

    // Begin the transaction.
    myTrans = myConnection.BeginTransaction();

    // Assign transaction object for a pending local transaction
    mysqlCommand.Transaction = myTrans;
   
    try
    {
        // Insert the user record.
        mysqlCommand.CommandText = "Insert into useraccount VALUES
('"+uname+"','"+ufamily+"')";
        mysqlCommand.ExecuteNonQuery();
        // pass the data .transaction complete
        myTrans.Commit();
        return "transaction completed";
    }
    catch(Exception e)
    {
        // transaction cancel
        myTrans.Rollback();
        return e.ToString()+"transaction abort";
    }

}

Rgds,
John Paul. A

> Can anyone tell me how to work with database transactions in a web service.
> Can anyone please give me a sample code.
Merline Martina - 23 Nov 2004 11:21 GMT
Thanks...
Can you give me few links please...

> Dear Merline Martina,
> Here is a sample code which explains about the database transactions in a
[quoted text clipped - 51 lines]
> > Can anyone tell me how to work with database transactions in a web service.
> > Can anyone please give me a sample code.
John Paul. A - 23 Nov 2004 11:53 GMT
Have a look at this page.

Web Services Transaction (WS-Transaction
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnglobspec/html
/ws-transaction.asp


Rgds,
John Paul. A

> Thanks...
> Can you give me few links please...
[quoted text clipped - 54 lines]
> > > Can anyone tell me how to work with database transactions in a web service.
> > > Can anyone please give me a sample code.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.