Today, I encountered an uncertain problem.
After the website is upgraded, a page cannot be accessed, and the message "Object Name" xxx "is invalid.
The xxx table is not created on the server, so you can open "SQL query analyzer ":
Export the SQL script for creating the xxx table as follows:
- CREATE TABLE [xxx] (
- [id] [int] IDENTITY (1, 1) NOT NULL ,
- [title] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL ,
- [kind] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL ,
- [content] [nvarchar] (1000) COLLATE Chinese_PRC_CI_AS NOT NULL ,
- [keyword] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
- [Add_Date] [datetime] NULL
- ) ON [PRIMARY]
Create a new one on the server and refresh it again. The prompt is: the object name "xxx" is invalid. You can pull bananas ~~
The possible cause for searching on Google is the database owner problem. The database may have different login accounts,
The database can belong to an account, so the problem arises.
If you log on to the logina account in the pubs database and create an x table, then log on to the loginb account and query the x table
The error message "xxx" is invalid.
Let me go !~
N
The ghost knows that the script just created the table to that user. So, I opened "Enterprise Manager" again ",
Select the table to export the SQL script. The script generated this time includes the owner:
- CREATE TABLE [logina].[xxx] (
- [id] [int] IDENTITY (1, 1) NOT NULL ,
- [title] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL ,
- [kind] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL ,
- [content] [nvarchar] (1000) COLLATE Chinese_PRC_CI_AS NOT NULL ,
- [keyword] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
- [Add_Date] [datetime] NULL
- ) ON [PRIMARY]
- GO
So I dropped the xxx table on the table server and ran the above script.
Refresh again, Niang SIPI! Or: the object name "xxx" is invalid.
My database access layer uses subsonic, so I read the code generated by subsonic and found that
One row:
- schema.SchemaName = @"dbo";
Wow! But the login name in the database connection string is not like this!
However, other tables seem to have no query problems ??????????????????????????????
Therefore, I added the following line to the code running on the server:
- output q.BuildSqlStatement();
You directly run the generated query code on the server, and the prompt is: the object name "xxx" is invalid.
My day ~!
In the generated script, the owner added before the xxx table is "dbo ~
Again, drop table xxx, and then:
- CREATE TABLE [dbo].[xxx] (
- [id] [int] IDENTITY (1, 1) NOT NULL ,
- [title] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL ,
- [kind] [nvarchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL ,
- [content] [nvarchar] (1000) COLLATE Chinese_PRC_CI_AS NOT NULL ,
- [keyword] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL ,
- [Add_Date] [datetime] NULL
- ) ON [PRIMARY]
- GO
Refresh again. The cute girl is still shy .~~~
Summary:
1. Pay attention to the table owner issue in a real production environment.
2. Tables created by different owners cannot be accessed when other users log on. A message is displayed, indicating that the object name "xxx" is invalid.
3. Why does my login name be logina, but when logina is added, the system prompts that the object name "xxx" is invalid? Because subsonic
The generated script uses dbo. Why? Ghost knows ~~