Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open a SQL Connection and pass SQL script

Status
Not open for further replies.

WelshyWizard

IS-IT--Management
Joined
Apr 23, 2006
Messages
89
Location
GB
Hi all,

I'm new tothe whole world of .NET and I'm guessing that what I want to do is fairly easy.... But I just don't know how to do it!

We're running SQL Server 2000 and I am trying to opena connection to a database.
The database is called FMTEST and it resides on SQL Server SQLSVR1.
I want to open a connection to the database and pass the following two commands of SQL script to it:

Code:
UPDATE OPERATION SET RUN = (RUN/4)*3 WHERE RESOURCE_ID LIKE 'TI';
UPDATE OPERATION SET RUN_HRS = (RUN_HRS/4)*3 WHERE RESOURCE_ID LIKE 'TI';

I'd really appreciate some help on this!

Cheers

Today is the tomorrow you worried about yesterday - and all is well.....
 
Why don't you combine these two queries when they are going to be fired on same table at same instance.
Code:
UPDATE OPERATION SET RUN=RUN*3/4, RUN_HRS=RUN_HRS*3/4 WHERE RESOURCE_ID LIKE 'TI'
If you want, take help for Connection String here.

Sharing the best from my side...

--Prashant--
 
Yeah, good idea!

I've been to that connection string sight in the past. However, as I'm a complete novice I've no idea how to make it work for me. When I copy it in it doesn't recognise 'Driver', which I understand because it's not declared....

Also how do you fire a sql command through VB.NET?

Today is the tomorrow you worried about yesterday - and all is well.....
 
Just follow this MS article about everything related to DB programming.
Code:
        Dim strCon As String = "Data Source=SQLSVR1;Initial Catalog=FMTEST;Integrated Security=True;connection timeout=30"
        Dim con As New System.Data.SqlClient.SqlConnection(strCon)
Still if you find any problem, post exact error message so that we can help you.

Sharing the best from my side...

--Prashant--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top