Pooled Connection Strings

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

Hi-

I've got a pooled connection string I've written in C#.

namespace SomeProgram
{
static class Program
{
public static OleDbConnection DBConnectionString
{
get
{
string conn;
DataSet ds = new DataSet();
conn = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=DB
\\somedb.mdb";
OleDbConnection oleconn = new OleDbConnection(conn);
oleconn.Open();
return oleconn;
}
}

}

}

Now it works great in C#, but I'm trying to do the same thing in VB.
When I code the VB equivalent and try to reference it
(Program.DBConnectionString), it errors out and says that 'Program is
not defined'. Any suggestions and tips are more than welcome. Thanks.
 
Chris said:
Hi-

I've got a pooled connection string I've written in C#.

namespace SomeProgram
{
static class Program
{
public static OleDbConnection DBConnectionString
{
get
{
string conn;
DataSet ds = new DataSet();
conn = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=DB
\\somedb.mdb";
OleDbConnection oleconn = new OleDbConnection(conn);
oleconn.Open();
return oleconn;
}
}

}

}

Now it works great in C#, but I'm trying to do the same thing in VB.
When I code the VB equivalent and try to reference it
(Program.DBConnectionString), it errors out and says that 'Program is
not defined'. Any suggestions and tips are more than welcome. Thanks.

Show us the VB code?

LS
 
Hi-

I've got a pooled connection string I've written in C#.

namespace SomeProgram
{
static class Program
{
public static OleDbConnection DBConnectionString
{
get
{
string conn;
DataSet ds = new DataSet();
conn = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=DB
\\somedb.mdb";
OleDbConnection oleconn = new OleDbConnection(conn);
oleconn.Open();
return oleconn;
}
}

}

}

Now it works great in C#, but I'm trying to do the same thing in VB.
When I code the VB equivalent and try to reference it
(Program.DBConnectionString), it errors out and says that 'Program is
not defined'. Any suggestions and tips are more than welcome. Thanks.

Maybe SomeProgram.Program.DBConnectionString?
 
Imports System.Data
Imports System.Data.SqlClient
Imports Microsoft.VisualBasic

Public Class dbconn
Public Shared Function ConnString() As SqlConnection
Dim conn As String
conn = "DATA
SOURCE=SqlServer;UID=SomeID;PWD=SomePass;DATABASE=SomeDB"
Dim sqlconn As New SqlConnection(conn)
sqlconn.Open()
Return sqlconn
End Function
End Class
 
"name 'dbconn' is not defined."

You don't use the same names than in your C# program so program is not
deifned in your VB code. What if you try dbconn.ConnString insetad of
Program.DBConnectionString ?

--
Patrice

"Chris" <[email protected]> a écrit dans le message de (e-mail address removed)...
Imports System.Data
Imports System.Data.SqlClient
Imports Microsoft.VisualBasic

Public Class dbconn
    Public Shared Function ConnString() As SqlConnection
        Dim conn As String
        conn = "DATA
SOURCE=SqlServer;UID=SomeID;PWD=SomePass;DATABASE=SomeDB"
        Dim sqlconn As New SqlConnection(conn)
        sqlconn.Open()
        Return sqlconn
    End Function
End Class
 
Thanks! Looking at that I could see how the rest of them were set up,
and all I had to do was

Imports dbconn

Thanks again!
 
It's in there, and intellisense recognizes it when I write my code,
but the browser just refuses to recognize it.
 
Yeah, it's actually not working. I had removed your quoted post after
it crashed on me, so I'm still stuck...
 
Back
Top