-
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
Code:
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.
-
Re: Sql database query
That code doesn't seem to make sense. I'm not sure exactly how T-SQL would treat this line:
Code:
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.