SQL Server Performance

SQL connection with typed dataset.

Discussion in 'SQL Server 2005 General Developer Questions' started by terrence_chan99, May 4, 2006.

  1. terrence_chan99 New Member

    I have a question about the SQL connection.<br /><br />I am using VS2005 and SQL2005.<br /><br />I create a "Data Connection" using trusted connection when I set up a Typed Dataset.<br /><br />So the connection string is auto-generated and store in the Solution Properties Settings<br /><br />i.e.<br /><br />[global:<img src='/community/emoticons/emotion-7.gif' alt=':S' />ystem.Configuration.DefaultSettingValueAttribute("Data Source=SERVERNAME;Initial Catalog=MyApplication;Integrated Security=True;Application Name="APPLICTIONNAME"")]<br /><br />public string MyApplicationConnectionString {<br /><br />get {<br /><br />return ((string)(this["MyApplicationConnectionString"]));<br /><br />}<br /><br />}<br /><br />I have a login screen which capture the username and password to make a connection string,<br /><br />i.e.<br /><br />SqlConnection conn = new SqlConnection();<br /><br />conn.ConnectionString = "data source=localhost;initial catalog=MyApplication" +<br /><br />";User Id=" + strName + "<img src='/community/emoticons/emotion-4.gif' alt=';P' />assword=" + strPassword +<br /><br />";Application Name=MyApplication"; <br /><br />Questions<br /><br />I want the retrieve of all data are using this 2nd connection string instead of MyApplicationConnectionString. <br /><br />As you see I have two connection strings. I wonder at the run-time, what connectionstring will the typed dataset use? I assume it will be the "MyApplicationConnectionString", if so, how I can force is to use the second connectionstring(conn)?<br /><br />Thanks!<br /> <br />
  2. joechang New Member

    the initial conn str is the first one,
    however when the second set of code is executed, the conn string changes.
    so, assuming you open the connection after executing the 2nd code set, its the 2nd one

Share This Page