robblot avatar image
robblot asked

Column 'PrinterID' does not belong to table Printers

This is the table I am trying to insert data, but when I run my program I keep getting this error;

Column 'PrinterID' does not belong to table Printers.

I have recreated this table twice. Also this is the stored procedure I use. I use this same schema for my other tables and they work fine. Is this enough information? What am I doing wrong?

PrinterID         uniqueidentifier     Unchecked
PrinterName       varchar(25)            Unchecked
PrinterModel          varchar(10)            Checked
PrinterPhase          varchar(8)             Checked
PrinterConnectionType   varchar(10)          Checked
PrinterIPAddress          varchar(15)            Checked
PrinterVoltage        varchar(8)             Checked
PrinterLocation       varchar(25)            Checked
PrinterAssignment         varchar(15)            Checked
PrinterPurpose        varchar(15)            Checked
PrinterContent        varchar(15)            Checked
PrinterSides          varchar(10)            Checked
PrinterFaxStationName   varchar(25)          Checked
PrinterFaxID          varchar(25)            Checked
PrinterNotes          varchar(2500) Checked
PrinterSerialNumber     varchar(15)          Checked
PrinterTLINumber          varchar(15)            Checked
PrinterActive         bit           Checked
PrinterRetired        bit                     Checked
PrinterOnHold         bit               Checked
PrinterReasonForUpdate  varchar(2500)   Checked
PrinterSetupDate          smalldatetime Checked
PrinterRetiredDate      smalldatetime   Checked
PrinterRetiredCount     int                   Checked
PrinterUpdateDate         smalldatetime         Unchecked

USE [LabReports]
/****** Object:  StoredProcedure [dbo].[InsertPrinter]    Script Date: 06/21/2010 22:37:05 ******/
-- =============================================
-- Author:      Robert Blot
-- Create date: 04/04/2010
-- Description: This procedure will INSERT a printer into the Printers table
-- =============================================
ALTER PROCEDURE [dbo].[InsertPrinter] 
    -- Add the parameters for the stored procedure here
    @PrinterID      uniqueidentifier, 
    @PrinterName        varchar(25),
    @PrinterModel       varchar(10),
    @PrinterPhase       varchar(8),
    @PrinterConnectionType     varchar(10),
    @PrinterIPAddress            varchar(15),
    @PrinterVoltage     varchar(8),
    @PrinterLocation        varchar(25),
    @PrinterAssignment      varchar(15),
    @PrinterPurpose     varchar(15),
    @PrinterContent     varchar(15),
    @PrinterSides       varchar(10),
    @PrinterFaxStationName  varchar(25),
    @PrinterFaxID       varchar(25),
    @PrinterNotes       varchar(2500),
    @PrinterSerialNumber    varchar(15),
    @PrinterTLINumber       varchar(15),
    @PrinterActive      bit,
    @PrinterRetired     bit,
    @PrinterOnHold      bit,
    @PrinterReasonForUpdate varchar(2500),
    @PrinterSetupDate       smalldatetime,
    @PrinterRetiredDate smalldatetime,
    @PrinterRetiredCount    int
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.

-- Insert statements for procedure here
    (PrinterID, PrinterName, PrinterModel, PrinterPhase,  PrinterConnectionType,
        PrinterIPAddress, PrinterVoltage, PrinterLocation, PrinterAssignment, PrinterPurpose,
        PrinterContent, PrinterSides, PrinterFaxStationName, PrinterFaxID, PrinterNotes,
        PrinterSerialNumber, PrinterTLINumber, PrinterActive, PrinterRetired, PrinterOnHold,
        PrinterReasonForUpdate, PrinterSetupDate, PrinterRetiredDate, PrinterRetiredCount,
    (@PrinterID, @PrinterName, @PrinterModel, @PrinterPhase, @PrinterConnectionType,
        @PrinterIPAddress, @PrinterVoltage, @PrinterLocation, @PrinterAssignment, @PrinterPurpose,
        @PrinterContent, @PrinterSides, @PrinterFaxStationName, @PrinterFaxID, @PrinterNotes,
        @PrinterSerialNumber, @PrinterTLINumber, @PrinterActive, @PrinterRetired, @PrinterOnHold,
        @PrinterReasonForUpdate, @PrinterSetupDate, @PrinterRetiredDate, @PrinterRetiredCount,
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Scot Hauder avatar image
Scot Hauder answered

Sounds like your typed dataset is out of sync with the database, are you using Entity Framework or LINQ? The csdl/ssdl or dbml probably need updating.

LINQ: Delete the Printers table from the .dbml file and re-add it from server explorer

EF: Right-click the .edmx file in the Model Browser window and select Update Model from Database

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Magnus Ahlkvist avatar image
Magnus Ahlkvist answered

If I understand you correctly, this error message comes from the program calling the stored procedure. If so - please provide the full error message, preferably with a stack trace.

Have you tried running the stored procedure from a query window in SQL Server Management Studio?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.