|
-
May 20th, 2004, 10:10 AM
#1
Thread Starter
Frenzied Member
sqlClient Connection [RESOLVED]
in vb, I use this to open a connection:
VB Code:
Public Sub Connect(ByVal db As SqlClient.SqlConnection)
'Overloaded
'This is for a sqlConnection
'Kill the connection if it is open
'Then open the connection
KillConnection(db)
db.Open()
End Sub
Public Sub KillConnection(ByVal DB As SqlClient.SqlConnection)
If DB.State <> ConnectionState.Closed Then
DB.Close()
End If
End Sub
That ensures that a connection is closed beforehand. In c#, I'm trying the same:
PHP Code:
public void Connect(SqlConnection db)
{
KillConnection(db);
db.Open;
}
public void KillConnection(SqlConnection db)
{
if (db.State !=System.Data.ConnectionState.Closed)
{
db.Open;
}
}
I'm getting build errors on the db.Open part.
A couple of questions pop up for me. First, of course, is how do I get this to work?! Second, does this have something to do with the fact that Option Strict is on in C#? I know C# is more of a stronger typed language and I actually expected something like this to happen.
Last edited by Andy; Aug 13th, 2004 at 12:08 PM.
-
May 20th, 2004, 01:24 PM
#2
yay gay
in c# methods have ()
you must ALWAYS put the ()
so..
Open();
you'll see as it is MUCH better than in VB, that way you know if Open is a method or a variable just by looking at it
\m/  \m/
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|