Solved

How to run a SQL script

Posted on 2011-09-11
7
424 Views
Last Modified: 2012-08-14
I've been developing VB6 apps for many years, and now I have to develop a VB10 (Visual Studio 2010) database app that is to be hosted on the web.

I've created the program, which connects to a local SQL Server database, and it runs ok

I've uploaded the code to a Fasthosts folder via FTP, and I've created a SQL Server database with Fasthosts, which has an IP address, user name and password

What I cannot figure out is how to upload the database schema and data to Fasthosts !!

VS 2010's Database Publishing Wizard let me create a .SQL script file, but how and where do I run it?

I'm sure this is fairly straightforward, but I can't find out what to do next

Grateful for any help
Geoff
0
Comment
Question by:lybreeze
7 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 36518913
you have to read the file contents, and use the connection's execute method for the sql.

however, there is a gotcha, if there are lines that are just "GO", you have to split the file contents by the separator, because GO is not t-sql, actually.

hope this clarifies
0
 

Author Comment

by:lybreeze
ID: 36519301
Thanks for your reply.

However, could you please provide a bit more detail about how I go about reading the file contents and using the connection's execute method.  Where am I to do this - in VS 2010 or when connected to Fasthosts?

Thanks
Geoff
0
 
LVL 50

Accepted Solution

by:
Lowfatspread earned 250 total points
ID: 36519347
what interface do fasthosts provide for you to adminisiter you site/server?

you are probably best to contact there support line.
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

Author Comment

by:lybreeze
ID: 36519482
Thank you. I'll give them a call and get back
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 36521639
here some example:
http://social.msdn.microsoft.com/Forums/en-US/adodotnetdataproviders/thread/ee667e6d-d34a-48b4-b0f1-de875c183f3f/
check that you get the code that reads the file AND splits by the GO line ...
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 250 total points
ID: 36526396
FastHost has a PDF guide regarding their SQL Server and it appears that you can connect your Management Studio to their servers directly which means you can directly import export stuff

http://help.fasthosts.co.uk/euf/assets/pdf-guides/Getting-started-with-MS-SQL.pdf

http://msdn.microsoft.com/en-us/library/ms141209.aspx
0
 

Author Closing Comment

by:lybreeze
ID: 36554214
Thank you to you all for your help.

I contacted Fasthosts, and they suggested I use SQL Server Management Studio, a link to which is available on their website (although there seems a bit of confusion about the Express and Compact versions - can anyone shine any light on this?)

However, when I tried to install that on my PC with VS2010 it didn't install, probably because VS2010 already includes a copy of SQL Server (accessed via the Server Explorer and Solution Explorer tabs).  The problem is that when I use the SQL Server built into VS2010 it will only connect to a local server, not to a remote one.

I've got round it by installing SQL Server Management Studio on a separate PC, and creating the SQL Server database on that machine.  Nevertheless, I'm sure that I'm missing something here, as it ought to be possible to administer a remote database using VS2010 !!

Thanks again
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Reading the web config for a running service on Windows 10 16 42
Webservices in T-SQL 3 31
Database Connections Not being returned to Connection Pool 7 27
SQL Error - Query 6 26
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question