Solved

Error running Sql script in win app

Posted on 2008-10-09
12
1,958 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

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

Author Comment

by:Adnan
Comment Utility
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
Comment Utility
if i run the script direct in sql server then it run ok, but not true the application...
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 26

Expert Comment

by:Anurag Thakur
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
sorry ragi0017 i still do not understand, iam not so god in scripting and Database..... :(
0
 

Author Closing Comment

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

Expert Comment

by:modus_operandi
Comment Utility
Sample file removed.
 
modus_operandi
EE Moderator
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now