Sql Server Script File(.sql) Execution by Vb.net Code

I have a problem.

I m working on "light weight sql server"  project.

 

and i want to execute .sql file through vb.net code with the help of sqldmo library and sqlns namespace.

but i donot know any method to directly execute the .sql file.

i am successfully making the full script of select database of sql server.

 

please help me....

thanks....

0
amrit
5/20/2005 4:23:03 AM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

1 Replies
1787 Views

Similar Articles

[PageSpeed] 16

Hi,

You can use SQL-DMO object in your .net projects by referencing Sqldmo.dll  file which is in  C:\Program Files\Microsoft SQL Server\80\Tools\Binn  folder is default installation parameters are used.

I'm adding below a script which I could successfully run on my development environment. I hope it helps.

Dim sServer As SQLDMO.SQLServer = New SQLDMO.SQLServer

sServer.Connect("ERALPER", "loginname", "password")

Dim oDataBase As SQLDMO.Database

Dim strSQL As String

Dim f As System.IO.File

Dim strR As System.IO.StreamReader

strR = f.OpenText(strPath)

strSQL = strR.ReadToEnd()

sServer.Databases().Item("DBName").ExecuteImmediate(strSQL)

 

Eralper

http://www.kodyaz.com

 


http://www.eralper.com
http://www.kodyaz.com
0
eralper
5/20/2005 10:15:19 AM
Reply:

Similar Artilces:

SQL Server Reporting Services for SQL SERVER 2000 AND Visual Studio.NET 2005 .NET 2.0
Hi, Which version of SQl Server Reporting Services will work with SQL SERVER 2000 in pararrel with ASP.NET 2.0 (.NET 2.0 framework)?  Thanks, Azam HighOnCodingWanna get high! Hi, Okay I got the answer. Yes, we can use the SQL SERVER 2005 Reporting Services with SQL SERVER 2000. HighOnCodingWanna get high! ...

Attach SQL DB to SQL Server 2005 using VB.Net
Is there any way to attach a SQL DB to SQL Server 2005 using VB.Net?  If so can you also set security? Can you rephrase your question? Attach SQL DB from which version of SQL server ? Look up books online for sp_attachdb and sp_detachdb.***********************Dinakar NethiLife is short. Enjoy it.*********************** I have a DB that was created in SQL Server 2005.  I have a website that displays data from systems all over the world.  Each system sends it's data to it's own DB.  The customer can then go to a website and see the data at real time.  What ...

SQL Server 05 & .NET .dll's: executing .dll from T-SQL
Can I manually execute a .dll stored in SQL Server 2005?Is it possible for this .dll to do anything: call a Web Service, process XML, etc?Thanks. ...

How to Execute a SQL (.sql) script from within VB?
Hello, I am trying to figure out the best way to make VB6 execute an auto-generated .SQL file from SQL Server 2000. SQL Server 2000 has created a script (about 1000 lines long), creating views and SPs, and I need to execute said script from a VB client application. Similar to the effect of pasting it into the Query Analyser, only automated. Anyone have a suggestion (besides reformatting evey like and hard-coding it?) Thanks a ton! read it into a string, and execute it as normal.Kay LeeMySpace.com - http://www.myspace.com/kragieInfrastructure GroupMySpace.com- Code to live, but ...

running a sql script file through .net code
can anyone tell me how to run the sql server script file saved on my disk through .net code and get the changes done in the database?   read the code file in memory and execute the SQL code by using a SQLcommand object. The sql command text will be the sql query file that you read from the fileVikram www.vikramlakhotia.comPlease mark the answer if it helped you Hi, Here are the steps you should follow to accomplish what you want. Step-1 : Read your SQL Script file into a StringBuilder Step-2 : Add the reference 'Miscrosoft SQLDMO Object Library'...

SQL code to stop and restart sql server 2005 and sql agent
Hi. I would like to restore a SQL Server 2005 database from a backup file. The problem is that the users which are using the site, prevent the restore operation from completing. So, I stop the sql server by right clicking the server name in management studio and selecting stop, wait for 3-4 minutes and restart it by clicking start. Then I can restore. So I am looking for code that can do these operations (including the wait). let me just add that I am using a named instance - and I want to stop and restart the instance. Please help, thanks in advance. I found this link http://...

SQL Server Express file to Sql Server
I would like to copy the schema and data of a sql server express database file to a SQL Server Database. How can this be done and what steps would I need to take?   Thanks for any helpTinyPond TinyPond:I would like to copy the schema and data of a sql server express database file to a SQL Server Database. How can this be done and what steps would I need to take? If you have Express Management Studio, you back backup your database, and them import it to SQL Server (or attach and reattach).Justs open SQL Server Express Management Studio, connect to your Express instanc...

Converting MDF files (SQL Server Express) to SQL Server 2005 WITHOUT having to buy SQL Server 2005 (I have Express). Personal WebSite Starter Kit
Hi (and HELP!),   I downloaded the Personal WebSite Starter Kit and got it working no problem on my local machine.  But I've had nothing but frustration trying to get it up and running on a webhosting site.  I picked hostmysite.com which uses SQL Server 2005.  I was under the impression that it wouldn't be that big a deal to convert the .MDF files that Sql Server Express uses to a SQL Server 2005 database.  I tried using SQL Server Management Studio Express.  I was able to "see" my remote database on hostmysite.com, but I was not able to import the .mdf file...

Converting MDF files (SQL Server Express) to SQL Server 2005 WITHOUT having to buy SQL Server 2005 (I have Express). Personal WebSite Starter Kit
Hi,Basically i built a webpage with Login and it's working well from my local machine.Right now, i'm using Database Publishing Wizard. the problem is how do i convert.MDF files to .SQL 2005 to get my database publish in the internet? thanks  Place your .MDF file in the App_Data directory, change the connection string accordingly and then publish your web site. ----------------------------------------------------------Please click Mark As Answer if this helped in solving your problem.  Please click "Mark As Answer" if this hepled in solving your problem. ...

Converting MDF files (SQL Server Express) to SQL Server 2005 WITHOUT having to buy SQL Server 2005 (I have Express). Personal WebSite Starter Kit
Hi (and HELP!),   I downloaded the Personal WebSite Starter Kit and got it working no problem on my local machine.  But I've had nothing but frustration trying to get it up and running on a webhosting site.  I picked hostmysite.com which uses SQL Server 2005.  I was under the impression that it wouldn't be that big a deal to convert the .MDF files that Sql Server Express uses to a SQL Server 2005 database.  I tried using SQL Server Management Studio Express.  I was able to "see" my remote database on hostmysite.com, but I was not able to import the .mdf files ...

Urgent! Upload text file to SQL Server in VB.NET
Hi Experts, I am working on an HR Web application which should upload applicant's resume to our SQL Server 2000, a BLOB column.However, it inserts without error, but the resume isn't stored in table at all. The table structure is:CREATE TABLE [dbo].[Mgmt_App_Resume_Table] ( [Applicant_ID] [smallint] NULL , [App_Resume] [image] NULL  ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]After the program executed, the Applicant_ID is inserted fine, but the App_Resume column is empty.  The file I uploaded is a MS word doc. and it's a resume.....Where did I do wrong?  Ple...

SQL A and SQL Server
Hi I heard SQL Server used to be owned by Watcom is this true? Is SQL Anywhere, therefore, similar to SQL Server? -- Regards, John Not quite true. SQL Anywhere was created by Watcom. SQLServer was created by Sybase, and Microsoft licensed the technology. So MSSQL and ASE have common roots, not SQLAnywhere. -- Paul Horan[TeamSybase] "John Kingan" <john.kingan@abibuildingdata.com> wrote in message news:40d82aa1$1@forums-1-dub... > Hi I heard SQL Server used to be owned by Watcom is this true? Is SQL > Anywhere, therefore, similar to SQL Ser...

SQL Server 2005 Installation problems with SQL Server Express & SQL Server 2000
Hi Guys, I have had SQL Server Express and Sql Server Management Studio Express installed on my machine for some time and recently tried to install a trial of SQL Server 2005 as well.  (Yes, I'm migrating from Visual Studio Express to Visual Studio Professional, just as in tended!) Everything went fine except that nothing seemed to be installed.  I searched in all the obvious places - both on the Start/Programs menu and on the hard-drive: nothing. A check under Add/Remove Programs showed that Sql Server 2005 Express was installed, but called SQL Server 2005. So after a number o...

VB.NET and SQL Server
Hello; I'm new to this forum so I hope this is the right place to post this question. I'd like to know if someone knows of a good tutorial about programming on VB.NET & SQL Server, stuffs like how to connect to a database, send queries.. I know about queries in Sql but what I need to know is how to send them to SQL Server. Thanks in advance Hi, Take a look at the walkthroughs provided on the MSDN. You can also view them online at http://msdn.microsoft.com, search for walkthrough. Also read the documentation for System.Data.SqlClient namespace, the sample code provi...

Web resources about - Sql Server Script File(.sql) Execution by Vb.net Code - asp.net.sql-datasource

Execution of Joseph Wood - Wikipedia, the free encyclopedia
Wood was convicted of two counts of first degree murder and two counts of aggravated assault against a police officer. He was sentenced to death ...

Cie Games Founder Justin Choi: Execution Key To Success On Facebook’s Gaming Platform
... its flagship game to continued success and some 5.9 million monthly average users . The key, according to Founder Justin Choi: Better execution. ...

SAP Retail Execution on the App Store
Read reviews, compare customer ratings, see screenshots, and learn more about SAP Retail Execution. Download SAP Retail Execution and enjoy it ...

Execution Bed - Flickr - Photo Sharing!
... the microphone; it is why I am here. There are few acts graver than when a government takes the life of one of its own citizens. Executions ...

(Raw Video) Taliban Execution of Two Women in Afghanistan - YouTube
PLEASE THIS IS VERY serious WARNING This video may be disturbing to many and what you are about to see may be hurtful to watch this story is ...

Executions of Afghans reviving resentment of Iran
Many Afghan refugees hope for a haven in their western neighbour but return with stories of abuse, torture and addiction

Pasquale Barbaro: Sydney figure evaded hitman execution in Leichhardt - DailyTelegraph Search Search
PASQUALE Barbaro is a well-known man around Sydney, with a family pedigree littered with dead bodies.

The Public Execution of Laquan McDonald
The cop who shot Laquan McDonald has been charged, and the information contained in the indictment is pretty horrifying : Rarely have officers ...

Deportation, torture, summary execution. What would you call it?
Deportation, beatings, torture, summary execution. What would you call it? by digby I wrote about Trump and "f" word today for Salon: Over ...

Liveblogging History: November 19, 1915: Execution of Joe Hill
**Wikipedia**: [Joe Hill](https://en.wikipedia.org/wiki/Joe_Hill): >Joe Hill, born Joel Emmanuel Hägglund in Gävle, Sweden, and also known as ...

Resources last updated: 12/3/2015 4:50:52 PM