Hi,

you can use it with WinForms:

- Create a Application Config (app.config) very similar to the web.config
- Add the System.Configuration Namespace to your project
- Get your Connectionstring
with System.Configuration.ConfigurationManager.ConnectionStrings[...]

On Wed, Aug 12, 2009 at 11:31 AM, m.quinn0909 <[email protected]>wrote:

>
> Hi,
>
> I can't tell whether you are making a web or win app.  This may not
> fix the issue but it's worth pointing out that you can reference the
> connection string from the web config in ASP.NET code behind and I am
> sure there must be a winforms means to do something similar.
>
> using System.Web.Configuration;
>
>                // Open a new connection using the connection string 'conn'
> stored
> in web config (need to use System.Web.Configuration for this)
>                string conn = WebConfigurationManager.ConnectionStrings
> ["conn"].ConnectionString;
>                SqlConnection myConnection = new SqlConnection(conn);
>                myConnection.Open();
>
> On Aug 11, 3:16 am, Pratik <[email protected]> wrote:
> > Hi,
> >
> > I am developing a Custom Data Grid for displaying the stock information
> for
> > my company.
> > The stock information is stored in back end database and my program is
> > getting data and displaying it in data grid.
> >
> > Everything is fine except for a login error that I am getting when I try
> to
> > view that data grid from any client machine.
> >
> > Following login error is displayed in place of datagrid:
> >
> > *Login failed for user '(null)'. Reason: Not associated with a trusted
> SQL
> > Server connection.*
> > **
> > This is my connection String:
> >
> > *SqlConnection sqlcon = new SqlConnection("Data Source=DATABASE SERVER
> NAME;
> > Initial Catalog=Database Name; Integrated Security=SSPI");*
> > **
> > Back end SQL Server (2005) is configured to permit both SQL Server and NT
> > (Windows Authentication) i.e. Mixed Mode.
> >
> > Please let me know what am I missing.
> >
> > Thanks,
> > Pratik
>

Reply via email to