473,573 Members | 4,155 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Stored procedure

I am trying to code an compile a stored procedure without success. So I
generated one using Microsoft Visule C# .Net. and it follows. One of the
problems is that it will not compile. Some of the message won't to put ';'
all over the place, I some need help!!! These are some of the compile
messages.

; expected
Cannot use more than one type in a for, using, fixed, or declaration
statement
= (cannot specify constructor arguments in declaration)
Identifier expected
Invalid expression term ')'
Invalid expression term ','

static void SubmitChangesVi aDataAdapter()
{
IF EXISTS (SELECT * FROM sysobjects WHERE name = 'InsertCommandD etail' AND
user_name(uid) = 'dbo')
DROP PROCEDURE [dbo].[InsertCommandDe tail];
GO

CREATE PROCEDURE [dbo].[InsertCommandDe tail]
{
@Param1 int,
@Param2 char(30),
@Param3 money,
@Param4 money,
@Param5 money,
@filler char(50)
}
AS
SET NOCOUNT OFF;
INSERT INTO services([service-code], [service-description],
[large-animal-cost], [medium-animal-cost], [small-animal-cost]) VALUES
(@Param1, @Param2, @Param3, @Param4, @Param5, @filler);
SELECT [service-code], [service-description], [large-animal-cost],
[medium-animal-cost], [small-animal-cost], [service-nbr] FROM services WHERE
([service-nbr] = @@IDENTITY) ORDER BY [service-code];
GO

}

--
Norm Bohana
Nov 17 '05 #1
2 4713
Hello nbohana,

Stored procedures do not live in C# code. They live in SQL Server
databases. You need to use the SQL Enterprise Manager tool to find your
database and open it. From there, assuming you have permission, you can add
the stored procedure.

Then, your C# code is free to call it.

It is called a stored procedure because it is a procedure that is stored in
the database.

Also note:
INSERT INTO services([service-code], [service-description],
[large-animal-cost], [medium-animal-cost], [small-animal-cost]) VALUES
(@Param1, @Param2, @Param3, @Param4, @Param5, @filler);
This is not a valid SQL statement. Your Insert Into statement has to have
the same number of fields in the first half as values in the second. You
have five fields in the first half, and six values in the second. I don't
know what "filler" means to you, but to me, it sounds like something we used
to use in ISAM databases (yes... my hair is grey in spots :-). Filler
fields are not used in SQL Server except in rare situations. My guess is
that you are applying information from another DB to the SQL Server system.

Also note: SELECT [service-code], [service-description], [large-animal-cost],
[medium-animal-cost], [small-animal-cost], [service-nbr] FROM services
WHERE
([service-nbr] = @@IDENTITY) ORDER BY [service-code];
The Order By clause is unnecessary. The Select statement above will only
select a single record, ever.

Also, using Identity columns is not always scalable. (In other words, it
becomes a hassle if you need to have multiple databases that share records).
May I suggest that you could use a 'uniqueidentifi er' column, and that your
C# app would create the value (Guid.NewGuid() ) and pass it with the new
record, rather than having the database create it? It's a good habit to
have.

Hope this helps,

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"nbohana" <nb*****@discus sions.microsoft .com> wrote in message
news:DE******** *************** ***********@mic rosoft.com...I am trying to code an compile a stored procedure without success. So I
generated one using Microsoft Visule C# .Net. and it follows. One of the
problems is that it will not compile. Some of the message won't to put ';'
all over the place, I some need help!!! These are some of the compile
messages.

; expected
Cannot use more than one type in a for, using, fixed, or declaration
statement
= (cannot specify constructor arguments in declaration)
Identifier expected
Invalid expression term ')'
Invalid expression term ','

static void SubmitChangesVi aDataAdapter()
{
IF EXISTS (SELECT * FROM sysobjects WHERE name = 'InsertCommandD etail' AND
user_name(uid) = 'dbo')
DROP PROCEDURE [dbo].[InsertCommandDe tail];
GO

CREATE PROCEDURE [dbo].[InsertCommandDe tail]
{
@Param1 int,
@Param2 char(30),
@Param3 money,
@Param4 money,
@Param5 money,
@filler char(50)
}
AS
SET NOCOUNT OFF;
INSERT INTO services([service-code], [service-description],
[large-animal-cost], [medium-animal-cost], [small-animal-cost]) VALUES
(@Param1, @Param2, @Param3, @Param4, @Param5, @filler);
SELECT [service-code], [service-description], [large-animal-cost],
[medium-animal-cost], [small-animal-cost], [service-nbr] FROM services
WHERE
([service-nbr] = @@IDENTITY) ORDER BY [service-code];
GO

}

--
Norm Bohana

Nov 17 '05 #2
Thanks Nick, I actually did create them in the sql server, I just didn't how
to use them.
"Nick Malik [Microsoft]" wrote:
Hello nbohana,

Stored procedures do not live in C# code. They live in SQL Server
databases. You need to use the SQL Enterprise Manager tool to find your
database and open it. From there, assuming you have permission, you can add
the stored procedure.

Then, your C# code is free to call it.

It is called a stored procedure because it is a procedure that is stored in
the database.

Also note:
INSERT INTO services([service-code], [service-description],
[large-animal-cost], [medium-animal-cost], [small-animal-cost]) VALUES
(@Param1, @Param2, @Param3, @Param4, @Param5, @filler);


This is not a valid SQL statement. Your Insert Into statement has to have
the same number of fields in the first half as values in the second. You
have five fields in the first half, and six values in the second. I don't
know what "filler" means to you, but to me, it sounds like something we used
to use in ISAM databases (yes... my hair is grey in spots :-). Filler
fields are not used in SQL Server except in rare situations. My guess is
that you are applying information from another DB to the SQL Server system.

Also note:
SELECT [service-code], [service-description], [large-animal-cost],
[medium-animal-cost], [small-animal-cost], [service-nbr] FROM services
WHERE
([service-nbr] = @@IDENTITY) ORDER BY [service-code];


The Order By clause is unnecessary. The Select statement above will only
select a single record, ever.

Also, using Identity columns is not always scalable. (In other words, it
becomes a hassle if you need to have multiple databases that share records).
May I suggest that you could use a 'uniqueidentifi er' column, and that your
C# app would create the value (Guid.NewGuid() ) and pass it with the new
record, rather than having the database create it? It's a good habit to
have.

Hope this helps,

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"nbohana" <nb*****@discus sions.microsoft .com> wrote in message
news:DE******** *************** ***********@mic rosoft.com...
I am trying to code an compile a stored procedure without success. So I
generated one using Microsoft Visule C# .Net. and it follows. One of the
problems is that it will not compile. Some of the message won't to put ';'
all over the place, I some need help!!! These are some of the compile
messages.

; expected
Cannot use more than one type in a for, using, fixed, or declaration
statement
= (cannot specify constructor arguments in declaration)
Identifier expected
Invalid expression term ')'
Invalid expression term ','

static void SubmitChangesVi aDataAdapter()
{
IF EXISTS (SELECT * FROM sysobjects WHERE name = 'InsertCommandD etail' AND
user_name(uid) = 'dbo')
DROP PROCEDURE [dbo].[InsertCommandDe tail];
GO

CREATE PROCEDURE [dbo].[InsertCommandDe tail]
{
@Param1 int,
@Param2 char(30),
@Param3 money,
@Param4 money,
@Param5 money,
@filler char(50)
}
AS
SET NOCOUNT OFF;
INSERT INTO services([service-code], [service-description],
[large-animal-cost], [medium-animal-cost], [small-animal-cost]) VALUES
(@Param1, @Param2, @Param3, @Param4, @Param5, @filler);
SELECT [service-code], [service-description], [large-animal-cost],
[medium-animal-cost], [small-animal-cost], [service-nbr] FROM services
WHERE
([service-nbr] = @@IDENTITY) ORDER BY [service-code];
GO

}

--
Norm Bohana


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
22115
by: dinesh prasad | last post by:
I'm trying to use a servlet to process a form, then send that data to an SQL server stored procedure. I'm using the WebLogic 8 App. server. I am able to retrieve database information, so I know my application server can talk to the database. I've determined the failure occurs when the the following statement is executed: cstmt.execute(); (due...
0
6690
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft Visual Basic .NET version of this article, see 308049. For a Microsoft Visual C++ .NET version of this article, see 310071. For a Microsoft Visual J#...
3
2793
by: Rhino | last post by:
I've spent the last couple of hours trying to figure out how to debug a Java stored procedure and am just going in circles. The last straw came when I got "Cannot open input stream for default" when I launched the IBM Distributed Debugger via D:\IBMDebug>idebug.exe -qdaemon -quiport=8000,8001 First, a bit of background. I am running DB2...
4
3177
by: Rhino | last post by:
Is it possible for a Java Stored Procedure in DB2 V7.2 (Windows) to pass a Throwable back to the calling program as an OUT parameter? If yes, what datatype should I use when registering the Throwable as an OUT parameter and what datatype should I use in the CREATE PROCEDURE and DROP PROCEDURE statements? Here's what I tried: - the method...
8
7913
by: Thomasb | last post by:
With a background in MS SQL Server programming I'm used to temporary tables. Have just started to work with DB2 ver 7 on z/OS and stumbled into the concept of GLOBAL TEMPORARY TABLE. I have created a temporary database with a tables space. Verified that DECLARE GLOBAL TEMPORARY TABLE TEMP (A INTEGER); INSERT INTO SESSION.TEMP VALUES(10);...
2
5445
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
0
2635
by: Amber | last post by:
Stored procedures are faster and more efficient than in-line SQL statements. In this article we will look at two SQL Server stored procedures; one using an input parameter and one not, and see how to call them from an ASP.Net page Every modern database system has a stored procedure language. SQL Server is no different and has a relatively...
3
3466
by: kd | last post by:
Hi All, How to debug a stored procedure? Thanks, kd
7
3439
by: Dabbler | last post by:
I'm using an ObjectDataSource with a stored procedure and am getting the following error when trying to update (ExecuteNonQuery): System.Data.SqlClient.SqlException: Procedure or Function 'UpdateRegistrant' expects parameter '@EMail', which was not supplied. The field value was null in the database and not changed in the FormView so is...
2
4092
by: jed | last post by:
I have created this example in sqlexpress ALTER PROCEDURE . @annualtax FLOAT AS BEGIN SELECT begin1,end1,deductedamount,pecentageextra FROM tax
0
8215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6432
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5605
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5296
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3737
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3743
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2227
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1325
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1048
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.