Click here to Skip to main content
15,901,122 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i get this Unhandled exception.
Invalid object name dbo.FakturaDb_Faktura

But the table name is like that, whats the problem?





C#
var dt = new DataTable();

           const string constring = @"Data Source = MARTIN; Initial Catalog = FakturaDB;Integrated Security = True";
           using (var con = new SqlConnection(constring))
           {
               using (var cmd = new SqlCommand("SELECT * FROM dbo.FakturaDB_Faktura", con))
               {
                   dataGridViewAllaFakturor.ColumnCount = 1;
                   cmd.CommandType = CommandType.Text;
                   using (var sda = new SqlDataAdapter(cmd))
                   {

                       sda.Fill(dt);
                       dataGridViewAllaFakturor.AutoGenerateColumns = false;
                       dataGridViewAllaFakturor.ReadOnly = true;


                       dataGridViewAllaFakturor.Columns[0].DataPropertyName = "FakturaNr";
                       dataGridViewAllaFakturor.Columns[0].Name = "FakturaNr";
                       dataGridViewAllaFakturor.Columns[0].HeaderText = @"FakturaNr";
Posted
Comments
David_Wimbley 4-Mar-14 11:34am    
Make sure your username that you are using to connect (looks like windows auth) has the proper permissions on that schema.
Amalraj Ramesh 4-Mar-14 11:42am    
check dbo.FakturaDB_Faktura is exist or not in FakturaDB

need more info about error in which line did u get this error...

Run this SELECT * FROM dbo.FakturaDB_Faktura query in visual studio to check if it is working on the database.
 
Share this answer
 
Comments
Kurac1 4-Mar-14 11:40am    
i Solved it should be
[FakturaDB].[dbo].[dbo.FakturaDB_Faktura]
Try this,
SELECT * FROM [dbo].[FakturaDB_Faktura]

-KR
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900