HI,
We have shifted our database from sqlserver2003 to sqlserver2005.
1. connection strings stored in web.config
2. fetch connectionn string function
3. call fetchConnection string function to connect to database
ISSUE: when button on apply page is clicked it does not go to next page and errors "page cannot be displayed" "cannot find server or dns error". When details are entered directly from applydetails page it does write to local instance of dtatabase but not to remote database instance.
i don't know whats is happening here. Can anybody suggest teh right solution for this.
We have shifted our database from sqlserver2003 to sqlserver2005.
1. connection strings stored in web.config
Code:
<!-- Machine name to connection string keys --> <add key="*777*" value="**ConnString_DEV" /> <add key="server2" value="**ConnString_TST" /> <add key="server1" value="**ConnString_PRD" /> <!-- Literal Connection String Keys --> <add key="**ConnString_DEV" value="Server=localhost; data source=*777*; database=dbname; User ID=xxx; password=xxx; Trusted_Connection=no; Initial Catalog=dbname; Persist Security Info=False" /> <add key="**ConnString_TST" value="Server=sqlserver2005.ad; data source=sqlserver2005; database=dbname; User ID=xxx; password=xxx; Trusted_Connection=no; Initial Catalog=dbname; Persist Security Info=False" /> <add key="**ConnString_PRD" value="Server=sqlserver2005.ad; data source=sqlserver2005; database=dbname; User ID=xxx; password=xxx; Trusted_Connection=no; Initial Catalog=dbname; Persist Security Info=False" /> <add key="IsTest" value="true" /> <add key="TestEmail" value="hhhhhhh"/>
Code:
Public Shared Function FetchConnString() As String 'Fetch machine name and retrieve the right connection string from web.config Dim strMachineName As String Dim strConnectionStringKey As String Dim strConnectionString As String strMachineName = System.Environment.MachineName If strConnectionStringKey <> Nothing Then strConnectionString = ConfigurationSettings.AppSettings(strConnectionStringKey) Else 'An unmatched machine name will default to _TST strConnectionString = ConfigurationSettings.AppSettings("**ConnString_TST") End If If strConnectionString <> Nothing Then FetchConnString = strConnectionString Else FetchConnString = "<WEB.CONFIG CONNECTION STRING ERROR>" End If End Function
Code:
Public Sub imgBtnProceedApplNY_Command(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs) Dim CommandName As String, connectionString As String Dim ID As Guid Dim conn As System.Data.SqlClient.SqlConnection Dim cmd As System.Data.SqlClient.SqlCommand Dim da As System.Data.SqlClient.SqlDataAdapter conn = New System.Data.SqlClient.SqlConnection conn.ConnectionString = clsDatabase.FetchConnString conn.Open() cmd = New System.Data.SqlClient.SqlCommand cmd.Connection = conn 'Dim ds As DataSet Dim DocName As String, FormName As String CommandName = e.CommandArgument Select Case CommandName Case "Filled" Case "Blank" 'bind(Nothing) ' This section used to run 'bind' and download a blank application form FormName = "ApplyNYBlank" 'DocName = DisplayProcessing.DocumentLookupFileName(FormName, "NY") DocName = "../Requests/DownloadDocument.aspx?DocName=" + FormName + "&state=" + "NY" Me.Response.Redirect(DocName, True) 'Case Else End Select conn.Close() End Sub
i don't know whats is happening here. Can anybody suggest teh right solution for this.
Comment