如何连接到托管服务器的数据库 [英] how to connect to database of hosted server

查看:96
本文介绍了如何连接到托管服务器的数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友们,



我有这个严重的问题...



我需要托管asp.net c#中的网站。我不知何故上传了asp.net代码文件到服务器但数据库没有连接。当我问服务器提供商时,他们告诉我可以使用localhost这样做,他们为我提供了用户名和密码以及数据库名称,但是如何连接到存在数据库的服务器。



我真的需要一些快速帮助!!!请回复asap

Dear frens,

I have this serious issue...

I need to host the site which is in asp.net c#. I somehow did uploaded the asp.net code files to the server but the database is not connected. When i ask the server providers, they informed that i can do that using localhost and they have provided me with username and password and the database name but how can i connect to that server where the database exist.

I seriously need some quick help !!!please reply asap

推荐答案

使用它们提供的连接详细信息来形成连接字符串。它将是以下几行:

Use the connection details they provides to form your connection string. It'll be somethign along the lines of:
@"Data Source=localhost\SQLEXPRESS;Initial Catalog=MyDB;User Id=xxxx;Password=xxxx;"



Or

@"Data Source=localhost\SQLSERVER;Initial Catalog=MyDB;User Id=xxxx;Password=xxxx;"

将它放在你的web.config文件中,这样你每次都没有重新编译,如果它错了......

Put it in your web.config file, so you don't have you recompile each time if it's wrong...


你需要改变你的<$如果你有的话,可以在Web配置中使用c $ c> ConnectionString 。



然后从代码使用ConnectionString连接到数据库。



要知道如何连接数据库 - [MSDN]连接到ASP.NET中的数据库 [ ^ ]。

了解更多关于 ConnectionStrings - www.con nectionstrings.com [ ^ ]。



您还可以在 Google 上找到相同主题的视频。
You need to change your ConnectionString in Web config if you have any.

Then from code connect to the Database using the ConnectionString.

To know how to connect to Database - [MSDN] Connecting to Databases in ASP.NET[^].
To know more about ConnectionStrings - www.connectionstrings.com[^].

You will also find videos on Google on the same topic.


这篇关于如何连接到托管服务器的数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆