how to read the data without database name
If possible to read the data from sql without database name only Server name and table 开发者_JAVA技巧name using c#??
Assuming you mean SQL Server (and most Database platforms that I'm familiar with)... No. You would need to find the database name.
There are ways to find so that you CAN know it by querying the server, but the best way is to ask the database administrator or someone who has the authority to give you permission.
No, this is not possible. SQL tables are stored in SQL databases. And you could perfectly fine have two tables with the same name in two different databases on the same server. So with only the table name and the server name you won't know which one of two tables to read.
In theory you could get a list of all databases using sp_databases (In SQL Server) and then iterate through them all checking system tables for a table with your name but in practical terms this will be slow, be a security nightmare (should you really be able to see all db's on the server?) and a table with the same name could exist in more than 1 database and you'd have no way of working out which was correct.
Short answer: Not really.
精彩评论