error in query with 2 tables in c# visual studio 2010
-
i remove inner semi-colon but the query has error again at from field . string Cmd = "SELECT * FROM Robberies_Table JOIN Branches_Table ON Robberies_Table.BranchCode =Branches_Table.BranchCode ";
A couple of things:
- What error does it come up with? Give us a fighting chance here.
- What happens if you run this query directly against your database?
I was brought up to respect my elders. I don't respect many people nowadays.
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier -
A couple of things:
- What error does it come up with? Give us a fighting chance here.
- What happens if you run this query directly against your database?
I was brought up to respect my elders. I don't respect many people nowadays.
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easierTHE QUERY RUN SUCCESSFULLY AND IS IN THIS FORMAT:
SELECT Robberies_Table.BankName, Robberies_Table.Region, Robberies_Table.BranchCode, Robberies_Table.[Date], Robberies_Table.Ammount,
Robberies_Table.Description, Robberies_Table.Robbery_ID, Robberies_Table.[Year], Branches_Table.BranchName
FROM (Robberies_Table INNER JOIN
Branches_Table ON Robberies_Table.BranchCode = Branches_Table.BranchCode)IN C# THE QUERY I WRITE IS LIKE THIS : string Cmd = "SELECT * FROM (Robberies_Table INNER JOIN Branches_Table ON Robberies_Table.BranchCode = Branches_Table.BranchCode);"; AND WHEN I RUN THE PROGRAM NOW ONLY THE RECORD IS UNDER THE BRANCHNAME IT APPEAR IN SCREEN THE DATA OF ROBBERIES TABLE DON'T SHOW ME
-
THE QUERY RUN SUCCESSFULLY AND IS IN THIS FORMAT:
SELECT Robberies_Table.BankName, Robberies_Table.Region, Robberies_Table.BranchCode, Robberies_Table.[Date], Robberies_Table.Ammount,
Robberies_Table.Description, Robberies_Table.Robbery_ID, Robberies_Table.[Year], Branches_Table.BranchName
FROM (Robberies_Table INNER JOIN
Branches_Table ON Robberies_Table.BranchCode = Branches_Table.BranchCode)IN C# THE QUERY I WRITE IS LIKE THIS : string Cmd = "SELECT * FROM (Robberies_Table INNER JOIN Branches_Table ON Robberies_Table.BranchCode = Branches_Table.BranchCode);"; AND WHEN I RUN THE PROGRAM NOW ONLY THE RECORD IS UNDER THE BRANCHNAME IT APPEAR IN SCREEN THE DATA OF ROBBERIES TABLE DON'T SHOW ME
So use that query in your code.
I was brought up to respect my elders. I don't respect many people nowadays.
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier -
So use that query in your code.
I was brought up to respect my elders. I don't respect many people nowadays.
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easierIN C# THE QUERY I WRITE IS LIKE THIS : string Cmd = "SELECT * FROM (Robberies_Table INNER JOIN Branches_Table ON Robberies_Table.BranchCode = Branches_Table.BranchCode);"; AND WHEN I RUN THE PROGRAM NOW ONLY THE RECORD IS UNDER THE BRANCHNAME IT APPEAR IN SCREEN THE DATA OF ROBBERIES TABLE DON'T SHOW ME IF I WRITE THE SAME THAT IS IN MY DATABASE QUERY C# SHOW ME MY CRYSTAL REPORT EMPTY SO I WRITE AS ABOVE AND HAS THE ABOVE ERROR DIDN'T SHOW ANYTHING: ------------------------ string Cmd = "SELECT Robberies_Table.BankName, Robberies_Table.Region, Robberies_Table.BranchCode, Robberies_Table.[Date], Robberies_Table.Ammount,Robberies_Table.Description, Robberies_Table.Robbery_ID, Robberies_Table.[Year], Branches_Table.BranchName FROM (Robberies_Table INNER JOIN Branches_Table ON Robberies_Table.BranchCode = Branches_Table.BranchCode);";
-
IN C# THE QUERY I WRITE IS LIKE THIS : string Cmd = "SELECT * FROM (Robberies_Table INNER JOIN Branches_Table ON Robberies_Table.BranchCode = Branches_Table.BranchCode);"; AND WHEN I RUN THE PROGRAM NOW ONLY THE RECORD IS UNDER THE BRANCHNAME IT APPEAR IN SCREEN THE DATA OF ROBBERIES TABLE DON'T SHOW ME IF I WRITE THE SAME THAT IS IN MY DATABASE QUERY C# SHOW ME MY CRYSTAL REPORT EMPTY SO I WRITE AS ABOVE AND HAS THE ABOVE ERROR DIDN'T SHOW ANYTHING: ------------------------ string Cmd = "SELECT Robberies_Table.BankName, Robberies_Table.Region, Robberies_Table.BranchCode, Robberies_Table.[Date], Robberies_Table.Ammount,Robberies_Table.Description, Robberies_Table.Robbery_ID, Robberies_Table.[Year], Branches_Table.BranchName FROM (Robberies_Table INNER JOIN Branches_Table ON Robberies_Table.BranchCode = Branches_Table.BranchCode);";
I don't know how many different ways I can put this, but try running the same query that you issue in your C# code in the SQL table. You can't run different queries and then expect them to be the same.
I was brought up to respect my elders. I don't respect many people nowadays.
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier -
I don't know how many different ways I can put this, but try running the same query that you issue in your C# code in the SQL table. You can't run different queries and then expect them to be the same.
I was brought up to respect my elders. I don't respect many people nowadays.
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier -
why is my query wrong at FROM ? i want to connect two tables so i can get some specific data but c# appear error. try { //Set the command string string Cmd = "SELECT * FROM Robberies_Table JOIN Branches_Table ON Robberies_Table.BranchCode =Branches_Table.BranchCode ;"; //create new new connection to the database OleDbConnection conn = new OleDbConnection(ConnectionString); //create new data adapter OleDbDataAdapter Adapter = new OleDbDataAdapter(Cmd, conn); //create new command builder OleDbCommandBuilder CmdBuilder = new OleDbCommandBuilder(Adapter); dTable = new DataTable(); Adapter.Fill(dTable); conn.Close(); } catch (Exception e) { MessageBox.Show(e.ToString()); } //return the search results on a datatable return dTable; }
Would you plaese remove the * and write the columns that you want to access after joining both the table like-- select column1,column2 from (table1 JOIN table2 where.....)
-
MY DATABASE IS ACCESS NOT SQL AND I OBSERVE THAT HAS MANY DIFFERENCES IN THE WAY YOU WRITE THE QUERY. BUT ITS OK I WILL TRY MORE AND I WILL FIND THE SOLUTION ANYWAY... THANK YOU :)
Please don't SHOUT. It's not polite. :) /ravi
My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
-
Please don't SHOUT. It's not polite. :) /ravi
My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
I am so sorry if i make you to understand like this. I say this, because i felt that i had made you to feel tired about my problem with query in c# so i had preferred to release you from this, because maybe the problem didn't be the query but something that affect it. i am sorry again ..
-
I am so sorry if i make you to understand like this. I say this, because i felt that i had made you to feel tired about my problem with query in c# so i had preferred to release you from this, because maybe the problem didn't be the query but something that affect it. i am sorry again ..
No worries! :) /ravi
My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com