Avatar of SmashAndGrab

asked on 

Set a string that can be access from the entire winform.

Hi Experts,

I have a winform that currently uses MS access as its database.  I am in the process of converting the database to SQL compact.

My current method of accessing the Access database is that I set a string at the beginning of the application and use it throughout the App.

see here:

//set the Connection String at the top of the app so it is accessible throughout the application.

 string conn1 = "Provider=Microsoft.JET.OLEDB.4.0;data source=C:\\Users\\Public\\Documents\\MCRS\\Resources\\DB\\MCRS_Data.mdb";

string conn2 = "Provider=Microsoft.JET.OLEDB.4.0;data source=C:\\Users\\Public\\Documents\\MCRS\\Resources\\DB\\MCRS_OTHER.mdb";

public WhateverTheFunctionIs() {

//call the connection string when accessing the database

   OleDbConnection objConn = new OleDbConnection(conn1 ));[/b]

            OleDbDataAdapter objComm = new OleDbDataAdapter("select Company + ',' + username AS MerchID,FullName, AD_Name from MCRS_LU_Users where active like 'y' and Merchandiser like 'y'", objConn);


Open in new window

My SQL Lite db is within the resources folder.
My Question is this:

How do I do the same with my SQL Compact database?
C#Microsoft SQL ServerASP

Avatar of undefined
Last Comment
ol muser

8/22/2022 - Mon