By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,344 Members | 1,142 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,344 IT Pros & Developers. It's quick & easy.

Running SQL script through VB

P: n/a
Hi all,

I have generated a huge SQL script which installs the whole database
starting from creating database, tables,creating procedures, creating users
and everything thats required by my application.
Now i am using a custom action to install that database on my machine by
a deployment project for my application. It creates database and tables but
throws exceptions while creating procedures.
I am putting all the SQL code in a single txt file and reading it to
execute query.

1. Can I use a single file for all operations ?
2. What I need to do for the procedures and create users ?

Thnx

Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Bontz,

1. Can I use a single file for all operations ?


I thought that it is not working or not recomended.

Use for every operation a command.executenonquery

However it is better to place this question in the newsgroup
microsoft.public.dotnet.framework.adonet

There are a lot of people active who know a lot of SQL coding and all active
ones are able to translate your question to VBNet.

I hope this helps

Cor
Nov 21 '05 #2

P: n/a
Hi,

http://www.microsoft.com/downloads/d...DisplayLang=en

http://www.red-gate.com/sql/sql_packager.htm

Ken
-------------------------------
"BONTZ" <BO***@discussions.microsoft.com> wrote in message
news:06**********************************@microsof t.com...
Hi all,

I have generated a huge SQL script which installs the whole database
starting from creating database, tables,creating procedures, creating users
and everything thats required by my application.
Now i am using a custom action to install that database on my machine by
a deployment project for my application. It creates database and tables but
throws exceptions while creating procedures.
I am putting all the SQL code in a single txt file and reading it to
execute query.

1. Can I use a single file for all operations ?
2. What I need to do for the procedures and create users ?

Thnx
Nov 21 '05 #3

P: n/a
Hi Joseph,

I am connecting through a default username (windows authentication) and my
setup is creating tables and users. So connection is not a problem.

The error I am getting while running a script (generated by SQL server
enterprise manager) was " 'Create Procedure' statement should appear on the
top of the module". I cut pasted the Create procedure code to the top of
script. Now the error is

create procedure dbo.dt_adduserobject
as
set nocount on
/*
** Create the user object if it does not exist already
*/
begin transaction
insert dbo.dtproperties (property) VALUES ('DtgSchemaOBJECT')
update dbo.dtproperties set objectid=@@identity
where id=@@identity and property='DtgSchemaOBJECT'
commit
return @@identity
SET QUOTED_IDENTIFIER OFF

SET ANSI_NULLS ON
GRANT EXECUTE ON [dbo].[dt_adduserobject] TO [public]
SET QUOTED_IDENTIFIER ON

SET ANSI_NULLS ON
Can you help me out ?

Thnx
"A use database statement is not allowed in a procedure or trigger"

whereAs in procedure I am nowhere using USE DATABSE statment. The code of my
create procedure is :


"Joseph Vinoth" wrote:
Hi,

I need two info from you to help

what is the error you are getting ?
which sql user are u connecting?

try with system abdministrator user name that is sa and the password

Regards
Joseph Vinoth
"Ken Tucker [MVP]" wrote:
Hi,

http://www.microsoft.com/downloads/d...DisplayLang=en

http://www.red-gate.com/sql/sql_packager.htm

Ken
-------------------------------
"BONTZ" <BO***@discussions.microsoft.com> wrote in message
news:06**********************************@microsof t.com...
Hi all,

I have generated a huge SQL script which installs the whole database
starting from creating database, tables,creating procedures, creating users
and everything thats required by my application.
Now i am using a custom action to install that database on my machine by
a deployment project for my application. It creates database and tables but
throws exceptions while creating procedures.
I am putting all the SQL code in a single txt file and reading it to
execute query.

1. Can I use a single file for all operations ?
2. What I need to do for the procedures and create users ?

Thnx

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.