Results 1 to 2 of 2

Thread: Sql database query

  1. #1

    Thread Starter
    Member Ahmed Shahni's Avatar
    Join Date
    Feb 2011

    Lightbulb Sql database query

    Dear Sir,

    I'm using SQLserver 2008 and I have a below mentioned Query working successfully, now my requirement is I want to execute the same code in vb.net (Visual Studio 2010) it is a update Table command so how to convert and run in vb.net

    DECLARE @Rt int
    SET @Rt = 0
    UPDATE DB.dbo.Sales
    SET @Rt = Total = @Rt + Area1 + Area2
    FROM DB.dbo.Sales
    Please please help me to solve it.

    Thanks in advance.
    Last edited by Ahmed Shahni; Apr 10th, 2011 at 03:01 AM. Reason: Spelling corrections

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Sydney, Australia

    Re: Sql database query

    That code doesn't seem to make sense. I'm not sure exactly how T-SQL would treat this line:
    SET @Rt = Total = @Rt + Area1 + Area2
    but can you explain what it's actually trying to do?

    Reagrdless, in VB.NET you interact with SQL Server using the SqlClient ADO.NET provider. Follow the CodeBank link in my signature and check out my thread on Retrieving & Saving Data. One of the examples calls SqlCommand.ExecuteNonQuery. That's the one you want to follow. You just need to adjust the SQL code and the parameters.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts


Click Here to Expand Forum to Full Width