c# - error in objConnect.Sql = Properties.Settings.Default.SQL; -
i have project graduate need work database.
i wrote code:
using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.windows.forms; namespace _11111 { public partial class form1 : form { databaseconnection objconnect; string constring; dataset ds; datarow drow; int maxrows; int inc = 0; public form1() { initializecomponent(); } private void form1_load(object sender, eventargs e) { try { objconnect = new databaseconnection(); constring = properties.settings.default.employeesconnectionstring; objconnect.connection_string = constring; objconnect.sql = properties.settings.default.sql; ds = objconnect.getconnection; maxrows = ds.tables[0].rows.count; navigaterecords( ); } catch (exception err) { messagebox.show(err.message); } } private void navigaterecords() { drow = ds.tables[0].rows[inc]; txtfirstname.text = drow.itemarray.getvalue(1).tostring(); txtsurname.text = drow.itemarray.getvalue(2).tostring(); txtjobtitle.text = drow.itemarray.getvalue(3).tostring(); txtdepartment.text = drow.itemarray.getvalue(4).tostring(); } } }
the error says:
error 1 '_11111.properties.settings' not contain definition 'sql' , no extension method 'sql' accepting first argument of type '_11111.properties.settings' found (are missing using directive or assembly reference?) d:\c# project\11111\11111\ 33 62 11111
i don't know add in setting section "select * tbl_employees"
in windows form, there's section called settings, can define properties key/value pair. in code, call key corresponding value. error message states there's no key called 'sql' in properties. add custom key following:
- open solution explorer.
- right click on project name , select, properties.
- in properties window, select settings option. open settings panel can add, edit, & delete custom settings.
Comments
Post a Comment