This project is read-only.
2
Vote

store procedure did not create

description

My code is having the below store procedure "tbl_address_GetByfk_locationid"; however, it does not generate the store procedure script for me. Can you show me how?

Thanks,
Louis
    public List<addressModel> GetByfk_locationid(Int32 fk_locationid)
    {
        List<addressModel> result = new List<addressModel>();

        try
        {
            using (SqlCommand cmd = GetNewCommand())
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "tbl_address_GetByfk_locationid";

                cmd.Parameters.AddWithValue("@fk_locationid", fk_locationid);

                IDataReader reader = null;
                try
                {
                    reader = intranetDbProvider.ExecuteReader(cmd);
                    addressModel.FieldsOrdinal fields = new addressModel.FieldsOrdinal(reader);
                    while (reader.Read())
                    {
                        addressModel model = new addressModel();
                        model.ReadData(reader, fields);
                        result.Add(model);
                    }
                }
                catch (Exception)
                {
                    throw;
                }
                finally
                {
                    if (reader != null)
                        reader.Close();
                }
            }
            return result;
        }
        catch (Exception)
        {
            throw;
        }       
    }

comments

louistoyama wrote Jul 25, 2014 at 10:32 PM

Table example


USE [intranet]
GO

/ Object: Table [dbo].[tbl_location] Script Date: 07/25/2014 17:31:30 /
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[tbl_location](
[locationid] [int] IDENTITY(1,1) NOT NULL,
[locationname] [varchar](50) NULL,
CONSTRAINT [PK_tbl_location] PRIMARY KEY CLUSTERED
(
[locationid] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO




USE [intranet]
GO

/ Object: Table [dbo].[tbl_address] Script Date: 07/25/2014 17:31:15 /
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[tbl_address](
[addressid] [int] IDENTITY(1,1) NOT NULL,
[firstname] [varchar](50) NULL,
[lastname] [varchar](50) NULL,
[address1] [varchar](255) NULL,
[address2] [varchar](255) NULL,
[city] [varchar](50) NULL,
[state] [varchar](2) NULL,
[zip] [varchar](5) NULL,
[fk_locationid] [int] NOT NULL,
CONSTRAINT [PK_tbl_address] PRIMARY KEY CLUSTERED
(
[addressid] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[tbl_address] WITH CHECK ADD CONSTRAINT [FK_tbl_address_tbl_location] FOREIGN KEY([fk_locationid])
REFERENCES [dbo].[tbl_location] ([locationid])
GO

ALTER TABLE [dbo].[tbl_address] CHECK CONSTRAINT [FK_tbl_address_tbl_location]
GO

kiquenet wrote Apr 13, 2015 at 7:54 AM

I use 3Tier C# pattern, and not Stored procedures scripts sql files is generated.
>   public Int32 Insert(PreguntasFrecuentesFAQModel model)
        {
            try
            {
                using (SqlCommand cmd = GetNewCommand())
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.CommandText = "PreguntasFrecuentesFAQ_Insert";
Any solution?