Re: Stored procedure
- From: "nbohana" <nbohana@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 31 May 2005 17:30:02 -0700
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 'uniqueidentifier' 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" <nbohana@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:DEF88E77-088E-48DD-B719-790A40F61038@xxxxxxxxxxxxxxxx
> >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 SubmitChangesViaDataAdapter()
> > {
> > IF EXISTS (SELECT * FROM sysobjects WHERE name = 'InsertCommandDetail' AND
> > user_name(uid) = 'dbo')
> > DROP PROCEDURE [dbo].[InsertCommandDetail];
> > GO
> >
> > CREATE PROCEDURE [dbo].[InsertCommandDetail]
> > {
> > @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
>
>
>
.
- Prev by Date: Re: Can't Capture Ctrl-F4 in MDI Form
- Next by Date: Re: Implementation of Singleton
- Previous by thread: Re: Can't Capture Ctrl-F4 in MDI Form
- Next by thread: Re: Implementation of Singleton
- Index(es):
Relevant Pages
|