473,396 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

connection string issue. not writing to database on remote server

5
HI,

We have shifted our database from sqlserver2003 to sqlserver2005.
1. connection strings stored in web.config
Expand|Select|Wrap|Line Numbers
  1.  <!-- Machine name to connection string keys --> 
  2. <add key="*777*" value="**ConnString_DEV" />
  3. <add key="server2" value="**ConnString_TST" />
  4. <add key="server1" value="**ConnString_PRD" />
  5.  
  6. <!-- Literal Connection String Keys -->
  7. <add key="**ConnString_DEV" 
  8. value="Server=localhost; data source=*777*;
  9. database=dbname;
  10. User ID=xxx;
  11. password=xxx;
  12. Trusted_Connection=no;
  13. Initial Catalog=dbname;
  14. Persist Security Info=False" />
  15.  
  16. <add key="**ConnString_TST" 
  17. value="Server=sqlserver2005.ad; data source=sqlserver2005;
  18. database=dbname;
  19. User ID=xxx;
  20. password=xxx;
  21. Trusted_Connection=no;
  22. Initial Catalog=dbname;
  23. Persist Security Info=False" />
  24.  
  25. <add key="**ConnString_PRD" 
  26. value="Server=sqlserver2005.ad; data source=sqlserver2005;
  27. database=dbname;
  28. User ID=xxx;
  29. password=xxx;
  30. Trusted_Connection=no;
  31. Initial Catalog=dbname;
  32. Persist Security Info=False" />
  33.  
  34. <add key="IsTest" value="true" />
  35. <add key="TestEmail" value="hhhhhhh"/> 
  36.  
2. fetch connectionn string function
Expand|Select|Wrap|Line Numbers
  1.  
  2. Public Shared Function FetchConnString() As String
  3.  
  4. 'Fetch machine name and retrieve the right connection string from web.config
  5.  
  6. Dim strMachineName As String
  7. Dim strConnectionStringKey As String
  8. Dim strConnectionString As String
  9.  
  10. strMachineName = System.Environment.MachineName
  11. If strConnectionStringKey <> Nothing Then
  12. strConnectionString = ConfigurationSettings.AppSettings(strConnectionStringKey)
  13. Else
  14. 'An unmatched machine name will default to _TST
  15. strConnectionString = ConfigurationSettings.AppSettings("**ConnString_TST")
  16. End If
  17.  
  18. If strConnectionString <> Nothing Then
  19. FetchConnString = strConnectionString
  20. Else
  21. FetchConnString = "<WEB.CONFIG CONNECTION STRING ERROR>"
  22. End If
  23.  
  24. End Function
  25.  
3. call fetchConnectionstring function to connect to database

Expand|Select|Wrap|Line Numbers
  1.  
  2. Public Sub imgBtnProceedApplNY_Command(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs)
  3.  
  4. Dim CommandName As String, connectionString As String
  5. Dim ID As Guid
  6.  
  7. Dim conn As System.Data.SqlClient.SqlConnection
  8. Dim cmd As System.Data.SqlClient.SqlCommand
  9. Dim da As System.Data.SqlClient.SqlDataAdapter
  10.  
  11. conn = New System.Data.SqlClient.SqlConnection
  12. conn.ConnectionString = clsDatabase.FetchConnString
  13. conn.Open()
  14.  
  15. cmd = New System.Data.SqlClient.SqlCommand
  16. cmd.Connection = conn
  17.  
  18. 'Dim ds As DataSet
  19. Dim DocName As String, FormName As String
  20.  
  21. CommandName = e.CommandArgument
  22.  
  23. Select Case CommandName
  24. Case "Filled"
  25.  
  26. Case "Blank"
  27. 'bind(Nothing)
  28. ' This section used to run 'bind' and download a blank application form
  29.  
  30. FormName = "ApplyNYBlank"
  31. 'DocName = DisplayProcessing.DocumentLookupFileName(FormName, "NY")
  32. DocName = "../Requests/DownloadDocument.aspx?DocName=" + FormName + "&state=" + "NY"
  33. Me.Response.Redirect(DocName, True)
  34. 'Case Else
  35. End Select
  36.  
  37. conn.Close()
  38.  
  39. End Sub
  40.  
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.
Jul 23 '08 #1
10 2291
Frinavale
9,735 Expert Mod 8TB
Make sure that your 2005 SQL Server has been configured to allow for remote connections.

I'm not sure why you'd be getting "page cannot be displayed" or "cannot find server or dns error" errors...Check your Web Server's event logs to see if any more details have been recorded there on why the page could not be displayed.

-Frinny
Jul 23 '08 #2
jimjim
5
Now the database is on the new server and from VS2005 its connected. but when I fill in details in a form and submit it does not write to the database on that server. currently I am not bothered about my local instance of the database. I wonder if the connection strings in Web.config is right or fetching the string in aspx page is ok
Jul 23 '08 #3
jimjim
5
After juggling with SQL Server and going thru the application form i see that the data entered was written to local instance of the database but not to the remote database. WHY
Jul 23 '08 #4
Frinavale
9,735 Expert Mod 8TB
After juggling with SQL Server and going thru the application form i see that the data entered was written to local instance of the database but not to the remote database. WHY
There has to be something preventing you from connecting to your remote SQL Server.

Check that your connection string is correct.
Check that your SQL Server accepts remote connections.
Check also that your SQL user connecting to the database has the appropriate rites to connect to the database.

Also check that there are no firewalls etc. blocking the connection.


-Frinny
Jul 24 '08 #5
jimjim
5
There has to be something preventing you from connecting to your remote SQL Server.

Check that your connection string is correct.
Check that your SQL Server accepts remote connections.
Check also that your SQL user connecting to the database has the appropriate rites to connect to the database.

Also check that there are no firewalls etc. blocking the connection.


-Frinny

I checked all of this. Remote connections are fine. Could you figure out if connection string has something to do with this. ALso the function FetchConnString() is not being called.
Jul 24 '08 #6
Frinavale
9,735 Expert Mod 8TB
I Also the function FetchConnString() is not being called.
The FetchConnString is your own function....I'm assuming it fetches the connection string.

I would suggest using the debugger to step through your application and determine why this function isn't being called.

-Frinny
Jul 24 '08 #7
The FetchConnString is your own function....I'm assuming it fetches the connection string.

I would suggest using the debugger to step through your application and determine why this function isn't being called.

-Frinny
I am unable to use the debugger in VS 2003. Could it be because I have VS2005 installed too. Also please tell me on dev environment I have datasource=machinename(say89899) and server=localhost - is this right. Also userid and password for the database on remote server. is it required in dev config.
Jul 25 '08 #8
Frinavale
9,735 Expert Mod 8TB
I am unable to use the debugger in VS 2003. Could it be because I have VS2005 installed too. Also please tell me on dev environment I have datasource=machinename(say89899) and server=localhost - is this right. Also userid and password for the database on remote server. is it required in dev config.

Please take a look at what the MSDN library has on Connection String Syntax to make sure that your connection string is correct.

Your "sever=localhost" will only work if the server is located on the same computer as the web server. I would recommend changing this to the name or IP of the computer instead of using localhost to see if it makes a difference.

-Frinny
Jul 25 '08 #9
Please take a look at what the MSDN library has on Connection String Syntax to make sure that your connection string is correct.

Your "sever=localhost" will only work if the server is located on the same computer as the web server. I would recommend changing this to the name or IP of the computer instead of using localhost to see if it makes a difference.

-Frinny
Can you be more specific with above statement. Also for datasource i am using my compauter name.
Jul 25 '08 #10
I set a breakpoint at page_load() and did stepinto process and whole events were going thru but doesn't step into imgbtnProceed() which calls the fetchstring() function and it doesn't get called.
Jul 28 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: JWM | last post by:
I am trying to implement Oracle connection pooling for the following code, which was written by someone else. Here is my main question -- this java file creates code that is executed every hour,...
18
by: WStoreyII | last post by:
I am making a asp page that will run on my computer by iis. But the problem is the database in on a web server. I can not seem to get the connection to work for it though here his the connection...
2
by: Maziar Aflatoun | last post by:
Hi guys, I'm using Windows authentication to connect to SQL Server 2000. On my computer the connection is fine. Now if I move it to a remote server, how to I hard code my Username/Password in...
1
by: vighnesh | last post by:
Hi All I am dealing a project in ASP.NET in which I have to establish a connection to SQL Server 2000 database,where the database was located on a remote system. For this I have used...
5
by: Mitya Mitriev | last post by:
Hi I created ASP.NET 2.0 web application that uses SQL Server 2000 database and it works perfectly when website and Sql server were on local machine. Then I installed application on production...
10
by: cleo | last post by:
I am migrating from VB6/Access to Visual Basic and SQL Express. I have success writing test code on my local machine and am now setting up tests for deployment to a server. I have installed SQL...
1
by: Chris | last post by:
hi I have big problem. I am writing a small win application. It will work on remote MS SQL database (2005). Firstly, I need to log on to the server. The server supports remote connections and sql...
2
by: samadams_2006 | last post by:
Hello, I have a problem that I'm hoping someone will be able to help me resolve. 1) I have a C# Web Site in which I connect to the database: "Install Microsoft SQL Server 2005 Express...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.