Click here to Skip to main content
15,917,862 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# ? Pin
James T. Johnson25-Jan-02 14:50
James T. Johnson25-Jan-02 14:50 
AnswerRe: C# ? Pin
Peter Stephens25-Jan-02 15:04
Peter Stephens25-Jan-02 15:04 
GeneralRe: C# ? Pin
James T. Johnson26-Jan-02 17:04
James T. Johnson26-Jan-02 17:04 
GeneralRe: C# ? Pin
27-Jan-02 5:43
suss27-Jan-02 5:43 
GeneralRe: C# ? Pin
James T. Johnson29-Jan-02 12:57
James T. Johnson29-Jan-02 12:57 
GenerallParam to LPNMHDR Pin
kasturirawat25-Jan-02 10:33
kasturirawat25-Jan-02 10:33 
GeneralGlobal database connection string in Windows Form Application Pin
kyledunn25-Jan-02 9:42
kyledunn25-Jan-02 9:42 
GeneralRe: Global database connection string in Windows Form Application Pin
Peter Stephens25-Jan-02 10:45
Peter Stephens25-Jan-02 10:45 
I use a static method to retrieve my database connection:

using System;
using System.Data.SqlClient;

namespace DbUtils {
    public class DataTools
    {
        public static String username = null;
        public static String password = null;

        public static SqlConnection GetConnection()
        {
            String connection = "database=mydb; network address=myserver; network library=dbnmpntw; "
            if(username != null)
                connection += "user id=\"" + username + "\"; ";
            if(password != null)
                connection += "password=\"" + password + "\"; ";

            return new SqlConnection(connection);
        }
    }
}


And then elsewhere in your app you just get a connection like:

SqlConnection conn = DbUtils.DataTools.GetConnection();


--
Peter Stephens
GeneralRe: Global database connection string in Windows Form Application Pin
kyledunn25-Jan-02 11:10
kyledunn25-Jan-02 11:10 
Generalinstallutil.exe Pin
omkamal25-Jan-02 9:08
omkamal25-Jan-02 9:08 
GeneralRe: installutil.exe Pin
James T. Johnson26-Jan-02 17:07
James T. Johnson26-Jan-02 17:07 
GeneralIncluding dotnetfx.exe in deployment project Pin
kyledunn25-Jan-02 8:37
kyledunn25-Jan-02 8:37 
GeneralRe: Including dotnetfx.exe in deployment project Pin
James T. Johnson25-Jan-02 9:05
James T. Johnson25-Jan-02 9:05 
GeneralRe: Including dotnetfx.exe in deployment project Pin
kyledunn25-Jan-02 9:26
kyledunn25-Jan-02 9:26 
GeneralPlease tell me why Pin
25-Jan-02 4:05
suss25-Jan-02 4:05 
GeneralRe: Please tell me why Pin
James T. Johnson25-Jan-02 7:33
James T. Johnson25-Jan-02 7:33 
GeneralRe: Please tell me why Pin
26-Jan-02 5:44
suss26-Jan-02 5:44 
GeneralPrinting, wrapping text, pagination, etc. Pin
kyledunn24-Jan-02 5:43
kyledunn24-Jan-02 5:43 
GeneralRe: Printing, wrapping text, pagination, etc. Pin
Peter Stephens25-Jan-02 7:55
Peter Stephens25-Jan-02 7:55 
GeneralRe: Printing, wrapping text, pagination, etc. Pin
kyledunn25-Jan-02 8:11
kyledunn25-Jan-02 8:11 
GeneralRe: Printing, wrapping text, pagination, etc. Pin
Peter Stephens25-Jan-02 10:16
Peter Stephens25-Jan-02 10:16 
GeneralRe: Printing, wrapping text, pagination, etc. Pin
kyledunn25-Jan-02 10:21
kyledunn25-Jan-02 10:21 
GeneralJust wondering about the lag... Pin
TheFLC23-Jan-02 21:50
TheFLC23-Jan-02 21:50 
GeneralRe: Just wondering about the lag... Pin
James T. Johnson24-Jan-02 7:49
James T. Johnson24-Jan-02 7:49 
GeneralRe: Just wondering about the lag... Pin
TheFLC24-Jan-02 9:36
TheFLC24-Jan-02 9:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.