上传 SQL Server 脚本?
我的总体目标是通过 FTP 将用 C# 创建并使用 SQLEXPRESS DB 的非常简单的 ASP.NET 网站上传到托管提供商。
据我了解,我可以毫无问题地获取所有 ASPX、.CS、母版页和图像文件。我遇到的问题和我在这里的原因是因为我无法简单地将我的 MDF 文件弹出到我的托管提供商(Verio Hosting)的站点中。
在网上,我遇到了 Scott Gu。在他的文章中,他写了如何将 MDF 转换为 .SQL 文件,您可以从网站上执行该文件。见下文....
如果您的托管商没有可用的 HTML 网络 管理工具,让您轻松 管理你的SQL数据库,然后你就可以 也只是写一个简单的ASP.NET页面 您 FTP(以及您的 .SQL 文件)到您的网站,然后点击 读取服务器上的.SQL 文件为 文本,然后将其作为字符串传递给 ADO.NET 来执行。这将给 你得到与查询相同的结果 上面的分析器 - 并完全创建您的 为您提供数据库。
我创建了 .SQL 文件,并且能够将此 .SQL 文件弹出到我的网站中。我向你们提出的问题是,如何创建一个简单的 ASP.NET 页面,然后我可以点击阅读该页面,然后执行 Scott 在上面的段落中提到的所有其他操作???
编辑:我发现我可以通过 SQL Mgt Studio 远程登录到我的托管提供商 SQL 服务器来重新创建我的数据库。我不想这样做有两个原因 1.) 知道有一种更酷的方法可以做到这一点感觉很便宜,2.) 我不知道如何重新创建我用于用户数据库的 ASPNETDB.MDF ASP.NET 为我创建的。
My over all goal is to upload a very simple ASP.NET web site created in C# and using a SQLEXPRESS DB to a hosting provider via FTP.
I understand that I can get all of my ASPX, .CS, master pages and image files with no problem. Problem I am having and reason I am here is because I cant simply pop my MDF file into my hosting provider's (Verio Hosting) site.
On the web I ran across a post by Scott Gu. In his post he wrote about converting a MDF into a .SQL file which you can execute from a web site. See below....
If your hoster has no usable HTML web
admin tool for allowing you to easily
manage your SQL database, then you can
also just write a simple ASP.NET page
that you FTP (along with your .SQL
file) to your web-site and then hit to
read the .SQL file on the server in as
text, and then pass it as a string to
ADO.NET to execute. This will give
you the same result as the query
analyzer above - and fully create your
database for you.
I created the .SQL file and I am capable of popping this .SQL file into my website. My question to you guys is how do I create that simple ASP.NET page that I can then hit to read, and then do everything else that Scott mentioned in the passage above????
EDIT: I found out that that I can just re-create my DB by remotely logging in to my hosting providers SQL server via SQL Mgt Studio. I dont want to do this for two reasons 1.) It feels cheap knowing that there is a much cooler way to do this, and 2.) I dont know how to re-create the ASPNETDB.MDF that I use for my user database that ASP.NET created for me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
流程的哪一部分你不明白?
它只是一个常规的 *.aspx Web 表单;您在后面的代码中完成所有工作。
顺便说一句,当通过 ADO.NET 向 SQL Server 发送命令时,请记住 ADO.NET 不理解“GO”语句;如果您的脚本包含它们,您要么必须解析它们并相应地提交批次,要么安排从您的页面调用命令行工具,例如
sqlcmd
(如果您的托管提供商允许的话)。Which part of the process don't you understand?
It's just a regular *.aspx web form; you do all of the work in the code behind.
BTW, when sending commands to SQL Server via ADO.NET, keep in mind that ADO.NET doesn't understand "GO" statements; if your script contains them, you will either have to parse them out and submit batches accordingly, or arrange to invoke a command-line tool like
sqlcmd
from your page, if your hosting provider allows it.您只需在 .SQL 文件中读取 ASP 页,该文件是一系列要执行的 SQL 查询。循环文件的内容,依次运行每个查询。查询将创建数据库模式、插入数据等。
You simply need to have the ASP page read in the .SQL file, which is a series of SQL queries to be executed. Loop though the contents of the file, running each query in turn. The queries will create the db schema, insert the data, etc.