开发者

configuring web.config for deployment with GoDaddy hosting

开发者 https://www.devze.com 2023-04-01 08:40 出处:网络
I have the following connection strings in development using visual studio web developer 2010 express:

I have the following connection strings in development using visual studio web developer 2010 express:

<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
<add name="ConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />
<add name="DatabaseConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\BegASPNET\Cheeztest\App_Data\Database.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True" providerName="System.Data.SqlClient" />
<add name="DatabaseEntities" connectionString="metadata=res://*/App_Code.CheeztestModel.csdl|res://*/App_Code.CheeztestModel.ssdl|res://*/App_Code.CheeztestModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />

What do I need to change/delete/keep in order to connect to a GoDaddy account with the following parameters:

Host Name: someresource.com Database Name: databasedb Username: databasedb Password: password

I am hosting on a GoDaddy account that only allows a single MS SQL database. In development I had two separate databases; one was ASPNETDB.MDF and the other was Database.MDF. Do I also need to have two separate databases in the hosted environment?

I forgot to mention that yes, GoDaddy does provide a configuration string. I have been trying for two days to make it work without success which is why I am posting here.

The string provided by GoDaddy is:

Data Source=somesource.com; Initial Catalog=databasedb;User ID=databsedb; Password=password;

Also, if necessary I can upgrade my GoDaddy account and get another database. Which I am willing to do if it will make my life easier.

UPDATE:

I changed connection strings to this:

<add name="ApplicationServices" connectionString="data source=leqaspnetdb.db.8311806.hostedresource.com;Initial Catalog=leqaspnetdb;User ID=leqaspnetdb; Password=Dan13206" providerName="System.Data.SqlClient" />
<add name="ConnectionString" connectionString="Data Source=leqaspnetdb.db.8311806.hostedresource.com;Initial Catalog=leqaspnetdb;User ID=leqaspnetdb; Password=Dan13206" providerName="System.Data.SqlClient" />
<add name="DatabaseConnectionString" connectionString="Data Source=leqaspnetdb.db.8311806.hostedresource.com;Initial Catalog=leqaspnetdb;User ID=leqaspnetdb; Password=Dan13206" providerName="System.Data.SqlClient" />
<add name="DatabaseEntities" connectionString="metadata=res://*/App_Code.CheeztestModel.csdl|res://*/App_Code.CheeztestModel.ssdl|res:
  //*/App_Code.CheeztestModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=leqaspnetdb.db.8311806.hostedresource.com;
  Initial Catalog=leqaspnetdb;User ID=leqaspnetdb;Password=Dan13206;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />

And I get this erro开发者_运维问答r:

Illegal characters in path.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Illegal characters in path.


You can certainly use one database in your hosted environment as long as there are no schema conflicts. You can have multiple connectionStrings in web.config pointing to the same database.

Here is an example connection string for discountasp.net hosting (sorry have nothing with goDaddy).

        <add name="TestDiscountAspNet"
    connectionString="Data Source=xxx.discountasp.net;Initial Catalog=SQL2008R2_837232_yyy;
    Persist Security Info=True;MultipleActiveResultSets=True;User ID=myUserName;Password=myPassword"
  providerName="System.Data.SqlClient"/>

If you still have any problem, please describe what the problem is.


Below is documentation on Godaddy about connecting to its database:

(http://support.godaddy.com/help/article/256/connecting-to-a-microsoft-sql-server-database-using-aspado?locale=en&ci=4606)

This example describes using ASP/ADO to connect to a Microsoft SQL Server Database.

Replace the db_ fields with the information for your database from the Control Panel in your hosting account. For more information, see Locating Your MS SQL Database Connection Strings for more information.

<%

'Sample Database Connection Syntax for ASP and SQL Server.

Dim oConn, oRs
Dim qry, connectstr
Dim db_name, db_username, db_userpassword
Dim db_server

db_server = "whsql01.mesa1.secureserver.net"
db_name = "your_dbname"
db_username = "your_dbusername"
db_userpassword = "your_dbpassword"
fieldname = "your_field"
tablename = "your_table"

connectstr = "Driver={SQL Server};SERVER=" & db_server & ";DATABASE=" & db_name & ";UID=" & db_username & ";PWD=" & db_userpassword

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open connectstr

qry = "SELECT * FROM " & tablename

Set oRS = oConn.Execute(qry)

Do until oRs.EOF
   Response.Write ucase(fieldname) & ": " & oRs.Fields(fieldname)
   oRS.MoveNext
Loop
oRs.Close


Set oRs = nothing
Set oConn = nothing

%>
0

精彩评论

暂无评论...
验证码 换一张
取 消