Invalid object name dbo.Images

Cliff Estes 1 Reputation point
2022-11-29T22:20:44.777+00:00

Database:
aspnet-BorrowedLightImages2022-31ddfd69-3493-469b-8cb0-3f0d286226b2; (Name copied from connectionstring)
aspnet-BorrowedLightImages2022-31ddfd69-3493-469b-8cb0-3f0d286226b2 (Name copied from SSMS)
aspnet-BorrowedLightImages2022-31ddfd69-3493-469b-8cb0-3f0d286226b2 (Name copied from VS2022 Server Object Explorer)

contains a table, dbo.Image   

SQL for that table:

CREATE TABLE [dbo].[Image] (  
	[Id]          INT            IDENTITY (1, 1) NOT NULL,  
	[ImgName]     NVARCHAR (MAX) NOT NULL,  
	[ImgPath]     NVARCHAR (MAX) NOT NULL,  
	[ImgKeywords] NVARCHAR (MAX) NOT NULL,  
	CONSTRAINT [PK_Image] PRIMARY KEY CLUSTERED ([Id] ASC)  

);

Connection string

Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=aspnet-BorrowedLightImages2022-31ddfd69-3493-469b-8cb0-3f0d286226b2;Integrated Security=True;Connect 	Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False  

SQL INSERT statement that throws the error:
"INSERT INTO dbo.Image (ImgName, ImgPath, ImgKeywords) VALUES ('1.jpg','Images\Slider','')"

Exception message
Invalid object name 'dbo.Image'

The INSERT query runs fine in SSMS.

I've tried surrounding "dbo" and "Image" with brackets thusly:
[dbo].[Image]
``to no avail.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,643 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,353 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Cliff Estes 1 Reputation point
    2022-11-30T01:42:55.847+00:00

    Resolved.

    Somehow the connectionstring was pointing to

    initial catalog=master

    I can't count how many times I checked the cs.

    Grrrr.

    Thx for the help.

    0 comments No comments