c# - Creating social website in asp.net -
i'm creating social networking website used "social networking website in asp.net - open source" http://www.c-sharpcorner.com/uploadfile/rahul4_saxena/social-networking-website-in-asp-net-open-source-project/ when tried run project on visual studio 2012 edition showing error below,
a network-related or instance-specific error occurred while establishing connection sql server. server not found or not accessible. verify instance name correct , sql server configured allow remote connections. (provider: named pipes provider, error: 40 - not open connection sql server) source error:
using system; using system.collections.generic; using system.linq; using system.web; using system.data; using system.data.sqlclient; /// <summary> /// summary description databaseclass /// </summary> public class databaseclass { sqldataadapter da; sqlconnection con; sqlcommand cmd = new sqlcommand(); dataset ds = new dataset(); datatable dt = new datatable(); public databaseclass() { // // todo: add constructor logic here // } public void connectdatabasetoinsert(string query) { con = new sqlconnection(@"data source=veena-sqlserver2008; initial catalog=rnetworkingwebapplication;"); cmd.commandtext = query; cmd.connection = con; da = new sqldataadapter(cmd); con.open(); cmd.executenonquery(); con.close(); } public dataset connectdatabasereturnds(string query) { ds = new dataset(); con = new sqlconnection(@"data source=veena-sqlserver2008; initial catalog=rnetworkingwebapplication;"); cmd.commandtext = query; cmd.connection = con; da = new sqldataadapter(cmd); da.fill(ds); con.open(); cmd.executenonquery(); con.close(); return ds; } public datatable connectdatabasereturndt(string query) { dt = new datatable(); con = new sqlconnection(@"data source=veena-sqlserver2008; initial catalog=rnetworkingwebapplication;"); cmd.commandtext = query; cmd.connection = con; da = new sqldataadapter(cmd); da.fill(dt); con.open(); cmd.executenonquery(); con.close(); return dt; } }
visual studio pointing error here da.fill(dt). have spent 2 days debug error still couldn't. please me.
it simple. code not able connect database. open server explorer in visual studio , connect database confirm able connect. , connection string right.
and have database, right?
Comments
Post a Comment