Click here to Skip to main content
15,922,574 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionGridview Paging Pin
venkata lakshmi prasanna21-Jul-07 1:19
venkata lakshmi prasanna21-Jul-07 1:19 
AnswerRe: Gridview Paging Pin
Fred_Smith21-Jul-07 5:21
Fred_Smith21-Jul-07 5:21 
AnswerRe: Gridview Paging Pin
Sathesh Sakthivel21-Jul-07 22:13
Sathesh Sakthivel21-Jul-07 22:13 
Questiondisplayin image Pin
boyindie21-Jul-07 0:24
boyindie21-Jul-07 0:24 
AnswerRe: displayin image Pin
Fred_Smith21-Jul-07 4:41
Fred_Smith21-Jul-07 4:41 
Questionconnection code in app_cofig file using windows form Pin
$h@ma!|@20-Jul-07 23:40
$h@ma!|@20-Jul-07 23:40 
AnswerRe: connection code in app_cofig file using windows form Pin
Sonia Gupta20-Jul-07 23:58
Sonia Gupta20-Jul-07 23:58 
AnswerRe: connection code in app_cofig file using windows form Pin
Psycho-*Coder*-Extreme21-Jul-07 6:37
Psycho-*Coder*-Extreme21-Jul-07 6:37 
First and foremost, this is a VB.Net question (Not ASP.Net since you are using Win Forms) second in your app.config you need a < connectionStrings > < /connectionStrings > section (like below) then add your connection string as I have. The weird thing about your post is you ask how to make it work in the app.config in Windows Forms then you ask how to call it on every "page" taht needs it, Windows Forms dont have "pages". The below example will work in Windows Forms (which is what you asked).

As for the 2nd part of your question, the easiest way to call it is to write a function like below:
'This returns the connection string
    Public Shared Function GetConnectionString(ByVal strConnection As String) As String
        Dim strReturn As New String("")
       'If you have multiple connection strings then you can pass it a connection name otherwise it defaults to your default connection
        If Not String.IsNullOrEmpty(strConnection) Then
            strReturn = ConfigurationManager.ConnectionStrings(strConnection).ConnectionString
        Else
            strReturn = ConfigurationManager.ConnectionStrings("MyConnectionName").ConnectionString
        End If
        Return strReturn
    End Function

Then on the form that needs a DB connection call it like this:
Dim oConnection As New SqlConnection(YourClassName.GetConnectionString("MyConnectionName"))

<connectionstrings>
        <add name="MyConnectionName">
   connectionString="Persist Security Info=False;Data Source=localhost;Initial Catalog=db;Integrated Security=SSPI;Trusted_Connection=TRUE;Application Name=AppName"
            providerName="System.Data.SqlClient" />
  </add>
</connectionstrings>


If you mis-worded your question and need this for an ASP.Net application (not Windows Forms) reply and let me know and I'll help as much as I can


"Well yes, it is an Integer, but it's a metrosexual Integer. For all we know, under all that hair gel it could be a Boolean."
Tom Welch


Questionvalidation checks in desktop application Pin
ooooooooppppppss20-Jul-07 23:27
ooooooooppppppss20-Jul-07 23:27 
AnswerRe: validation checks in desktop application Pin
Sonia Gupta20-Jul-07 23:40
Sonia Gupta20-Jul-07 23:40 
GeneralRe: validation checks in desktop application Pin
ooooooooppppppss20-Jul-07 23:50
ooooooooppppppss20-Jul-07 23:50 
GeneralRe: validation checks in desktop application Pin
Sonia Gupta21-Jul-07 0:05
Sonia Gupta21-Jul-07 0:05 
QuestionCreateUserWizard Inquiry Pin
Tethibogz20-Jul-07 22:08
Tethibogz20-Jul-07 22:08 
AnswerRe: CreateUserWizard Inquiry Pin
Sonia Gupta20-Jul-07 23:00
Sonia Gupta20-Jul-07 23:00 
GeneralRe: CreateUserWizard Inquiry Pin
Tethibogz21-Jul-07 9:34
Tethibogz21-Jul-07 9:34 
AnswerRe: CreateUserWizard Inquiry Pin
enjoycrack21-Jul-07 16:24
enjoycrack21-Jul-07 16:24 
QuestionDrag and Drop and upload images in IE Pin
Milind Panchal20-Jul-07 21:16
Milind Panchal20-Jul-07 21:16 
AnswerRe: Drag and Drop and upload images in IE Pin
Christian Graus20-Jul-07 21:24
protectorChristian Graus20-Jul-07 21:24 
AnswerRe: Drag and Drop and upload images in IE Pin
Sonia Gupta20-Jul-07 22:57
Sonia Gupta20-Jul-07 22:57 
GeneralRe: Drag and Drop and upload images in IE Pin
Milind Panchal20-Jul-07 23:19
Milind Panchal20-Jul-07 23:19 
Questionbutton click event firig twice .. Pin
Vipin.d20-Jul-07 20:37
Vipin.d20-Jul-07 20:37 
AnswerRe: button click event firig twice .. Pin
Christian Graus20-Jul-07 21:25
protectorChristian Graus20-Jul-07 21:25 
AnswerRe: button click event firig twice .. Pin
ballameharmurali21-Jul-07 0:11
ballameharmurali21-Jul-07 0:11 
QuestionUnable to connect to PUBS database Pin
KaKa'20-Jul-07 20:10
KaKa'20-Jul-07 20:10 
AnswerRe: Unable to connect to PUBS database Pin
Christian Graus20-Jul-07 21:39
protectorChristian Graus20-Jul-07 21:39 

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.