Solved

Error running Sql script in win app

Posted on 2008-10-09
12
1,963 Views
Last Modified: 2013-11-16
i get error message when i try to run my Sql script in my win app form.....

i get exception message saying thath:

'CREATE/ALTER PROCEDURE' must be the first statement in a query batch.
Incorrect syntax near the keyword 'PROCEDURE'.
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@Account_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@Balance".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@Account_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@Type_Id".
Must declare the scalar variable "@Type_Id".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@Client_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@Client_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@Engagement_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@MatchItem_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@FileType_ID".
Must declare the scalar variable "@FileType_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@ImpFile_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@MatchItem_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@Engagement_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@Engagement_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@Reconciled_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@ReconType_ID".
Must declare the scalar variable "@ReconType_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@Client_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@Setting_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@MatchItem_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@Type_ID".
Must declare the scalar variable "@Type_ID".
a USE database statement is not allowed in a procedure, function or trigger.
a USE database statement is not allowed in a procedure, function or trigger.

Do somone now how to fix this problom?
0
Comment
Question by:Adnan
  • 7
  • 4
12 Comments
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 22677125
your are trying to create a procedure from your windows application
can you share your sql that you send from your windows application
0
 

Author Comment

by:Adnan
ID: 22677161
oki, the script is very big, i am atachied the script. the script is for seting up the database for kustomer running ouer win app...!
0
 
LVL 26

Accepted Solution

by:
Anurag Thakur earned 500 total points
ID: 22677195
yes agreed the script is very big
i am assuming that you are trying to create the db through the application
i couldnt find out where but somewhere there is a GO missing
'CREATE/ALTER PROCEDURE' must be the first statement in a query batch.
normally comes if you have a normal statement like drop procedure and in the very next line you have a create procedure
maybe what i have explained will help you out or may be give you some direction to look for exception
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

Author Comment

by:Adnan
ID: 22677218
if i use Go in my script i get exception inncorect syntax near 'Go'...........
0
 

Author Comment

by:Adnan
ID: 22677268
Incorrect syntax near 'go'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near the keyword 'SET'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near the keyword 'SET'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near the keyword 'SET'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near the keyword 'SET'.
0
 

Author Comment

by:Adnan
ID: 22677275
if i run the script direct in sql server then it run ok, but not true the application...
0
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 22677286
found the issue
search for this
CREATE PROCEDURE [dbo].[RestoreAccess]

the above procedure and a lot of procedures are not being created as the procedures before that and you are getting error around this line i think

your create procedure line should be like this and not as its in the script file
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[InsertMatchItemXtra]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N''
End
0
 

Author Comment

by:Adnan
ID: 22677322
oki, but i dident understand how i can fin my procedure......can you show me how nad what you are meaning by creating procedure like u sayd?
0
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 22677897
search for text create procedure in your script file and where create procedure does not preceed with the text as i mentioned in my previous comment you will have to make changes
I think all the procedures after the procedure CREATE PROCEDURE [dbo].[RestoreAccess] were like that (if i remember correctly)
0
 

Author Comment

by:Adnan
ID: 22678198
sorry ragi0017 i still do not understand, iam not so god in scripting and Database..... :(
0
 

Author Closing Comment

by:Adnan
ID: 31504595
i made it... ;) thanks for helping...u guide me the right way
0
 
LVL 1

Expert Comment

by:modus_operandi
ID: 22787737
Sample file removed.
 
modus_operandi
EE Moderator
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

773 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