i have sql query want use results database. when try open sqlconnection, code won't compile , error asking if missing using directive.
using system; using system.collections.generic; using system.linq; using system.web; using system.web.ui; using system.web.ui.webcontrols; using system.io; using system.data; using system.data.sql; using system.data.sqlclient; using system.configuration; using system.collections; namespace hackoffice.superadmin { public partial class foundusbreakdown : system.web.ui.page { protected void page_load(object sender, eventargs e) { grabdata(); } private void grabdata() { string chartdataquery = "select accounttype, count(*) entries hackoffice.dbo.onlinesignups group accounttype"; using (sqlconnection connection = new sqlconnection(connectionstring)); } } } i'm confused because have same using directives on other pages , not getting same error on pages.
class names case sensitive in c#. need sqlconnection, not sqlconnection.
also, you're creating empty using statement dispose resource immediately. when open using block, you'll want put code uses idisposable resource inside block:
using (sqlconnection connection = new sqlconnection(connectionstring)) { // code uses sqlconnection goes inside block. }
Comments
Post a Comment