Re: Pooled Connection Strings

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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" <coz1978@xxxxxxxxx> a écrit dans le message de news:
81dc1b2a-bf41-48a2-9de3-c9791f30a539@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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

On Apr 1, 1:39 pm, Jack Jackson <jjack...@xxxxxxxxxxxxxxxx> wrote:
On Tue, 1 Apr 2008 08:03:47 -0700 (PDT), Chris <coz1...@xxxxxxxxx>
wrote:



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?


.



Relevant Pages

  • Re: Pooled Connection Strings
    ... "name 'dbconn' is not defined." ... Dim conn As String ... Dim sqlconn As New SqlConnection ... OleDbConnection oleconn = new OleDbConnection; ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Pooled Connection Strings
    ... Public Class dbconn ... Dim conn As String ... Dim sqlconn As New SqlConnection ... OleDbConnection oleconn = new OleDbConnection; ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Pooled Connection Strings
    ... "name 'dbconn' is not defined." ... Imports System.Data ... Dim conn As String ... Dim sqlconn As New SqlConnection ...
    (microsoft.public.dotnet.languages.vb)