c# and query result
-
When the query is work will call an insert query but when it is fail will appear a message that the record didn't founded in database
And what is your question? I can't see one in there at all.
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 -
And what is your question? I can't see one in there at all.
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 -
when the query is false how can i take the result so i can use it for doing something else with this
What query? How is it returning false? You haven't shown a query.
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 -
What query? How is it returning false? You haven't shown a query.
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 easierOleDbConnection dbConnDest; dbConnDest = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source= SystemA.accdb"); string query_select = "SELECT ReferenceYear FROM [MS Access;DATABASE=" + dialog.FileName +"].Questionnaires_Table1 Where ReferenceYear = '" + dateref.Text + "';"; OleDbCommand cmd_year = new OleDbCommand(query_select, dbConnDest); dbConnDest.Open(); string rfyear = cmd_year.ExecuteScalar().ToString();
-
OleDbConnection dbConnDest; dbConnDest = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source= SystemA.accdb"); string query_select = "SELECT ReferenceYear FROM [MS Access;DATABASE=" + dialog.FileName +"].Questionnaires_Table1 Where ReferenceYear = '" + dateref.Text + "';"; OleDbCommand cmd_year = new OleDbCommand(query_select, dbConnDest); dbConnDest.Open(); string rfyear = cmd_year.ExecuteScalar().ToString();
So all you're doing is testing to see if ReferenceYear exists? Why not just do SELECT Count(1)... instead, and then just evaluate the count? If it's zero, the record doesn't exist? Also, you may want to pay attention to the fact your select statement is vulnerable to a SQL Injection attack.
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 all you're doing is testing to see if ReferenceYear exists? Why not just do SELECT Count(1)... instead, and then just evaluate the count? If it's zero, the record doesn't exist? Also, you may want to pay attention to the fact your select statement is vulnerable to a SQL Injection attack.
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 easierExactly true.. :)
KiranKumar Roy
-
So all you're doing is testing to see if ReferenceYear exists? Why not just do SELECT Count(1)... instead, and then just evaluate the count? If it's zero, the record doesn't exist? Also, you may want to pay attention to the fact your select statement is vulnerable to a SQL Injection attack.
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 easierok i make a class and i have there the following code: public DataTable findrefyear(string dateref) { try { //Set the access command string string query_insert = "INSERT INTO Questionnaires_Table (BranchName,Factor,Region,Branch_ID,[Current_Date],No_Employees," + "No_Cashdesk,UrbanArea,TouristArea,RuralArea,GreenLinearArea,CentralStreets,EscapeBack,Collonization," + "TimeDelay,PatrolPolice,Visibility,SafeBoxRisk,StaffAccess,KeyboardActiviation,ConnectionKSC,GSMCommunicator,SystemAlarmRisk," + "InstalledSKKT,CheckSKKT,CheckDesk,CheckEntrance,SKKTRisk,RenovatedStore,MetalCashDrawers,ExtensionCash,Limits," + "CashDrawers,CasherRisk,WarningAlert,SecurityWarningDelay,WarningRisk,BothSideDoors," + "DoorsSound,ExitRisk,EmergencyCase,RobberyCase,DescriptionForm,SeminarRobbery,EducationRisk,ReferenceYear) " + "SELECT BranchName,Factor,Region,Branch_ID,Current_Date,No_Employees," + "No_Cashdesk,UrbanArea,TouristArea,RuralArea,GreenLinearArea,CentralStreets,EscapeBack,Collonization," + "TimeDelay,PatrolPolice,Visibility,(TimeDelay+PatrolPolice+Visibility)/3,StaffAccess,KeyboardActiviation,ConnectionKSC,GSMCommunicator,(StaffAccess+KeyboardActiviation+ConnectionKSC+GSMCommunicator)/4," + "InstalledSKKT,CheckSKKT,CheckDesk,CheckEntrance,(InstalledSKKT+CheckSKKT)/2,RenovatedStore,MetalCashDrawers,ExtensionCash,Limits," + "CashDrawers,(CheckDesk+CheckEntrance+RenovatedStore+MetalCashDrawers+ExtensionCash+Limits+CashDrawers)/7," + "WarningAlert,SecurityWarningDelay,(WarningAlert+SecurityWarningDelay)/2,BothSideDoors," + "DoorsSound,(BothSideDoors+DoorsSound)/2," + "EmergencyCase,RobberyCase,DescriptionForm,SeminarRobbery,(EmergencyCase+RobberyCase+DescriptionForm+SeminarRobbery)/4,ReferenceYear " + "FROM [MS Access;DAT
-
Exactly true.. :)
KiranKumar Roy
ok i make a class and i have there the following code: public DataTable findrefyear(string dateref) { try { //Set the access command string string query_insert = "INSERT INTO Questionnaires_Table (BranchName,Factor,Region,Branch_ID,[Current_Date],No_Employees," + "No_Cashdesk,UrbanArea,TouristArea,RuralArea,GreenLinearArea,CentralStreets,EscapeBack,Collonization," + "TimeDelay,PatrolPolice,Visibility,SafeBoxRisk,StaffAccess,KeyboardActiviation,ConnectionKSC,GSMCommunicator,SystemAlarmRisk," + "InstalledSKKT,CheckSKKT,CheckDesk,CheckEntrance,SKKTRisk,RenovatedStore,MetalCashDrawers,ExtensionCash,Limits," + "CashDrawers,CasherRisk,WarningAlert,SecurityWarningDelay,WarningRisk,BothSideDoors," + "DoorsSound,ExitRisk,EmergencyCase,RobberyCase,DescriptionForm,SeminarRobbery,EducationRisk,ReferenceYear) " + "SELECT BranchName,Factor,Region,Branch_ID,Current_Date,No_Employees," + "No_Cashdesk,UrbanArea,TouristArea,RuralArea,GreenLinearArea,CentralStreets,EscapeBack,Collonization," + "TimeDelay,PatrolPolice,Visibility,(TimeDelay+PatrolPolice+Visibility)/3,StaffAccess,KeyboardActiviation,ConnectionKSC,GSMCommunicator,(StaffAccess+KeyboardActiviation+ConnectionKSC+GSMCommunicator)/4," + "InstalledSKKT,CheckSKKT,CheckDesk,CheckEntrance,(InstalledSKKT+CheckSKKT)/2,RenovatedStore,MetalCashDrawers,ExtensionCash,Limits," + "CashDrawers,(CheckDesk+CheckEntrance+RenovatedStore+MetalCashDrawers+ExtensionCash+Limits+CashDrawers)/7," + "WarningAlert,SecurityWarningDelay,(WarningAlert+SecurityWarningDelay)/2,BothSideDoors," + "DoorsSound,(BothSideDoors+DoorsSound)/2," + "EmergencyCase,RobberyCase,DescriptionForm,SeminarRobbery,(EmergencyCase+RobberyCase+DescriptionForm+SeminarRobbery)/4,ReferenceYear " + "FROM [MS Access;DAT