sql server - System.Data.SqlClient.SqlException error at asp.net -
i new @ asp.net. trying database connection. getting error. please advice me.
using system; using system.collections.generic; using system.data.sqlclient; using system.linq; using system.web; using system.web.ui; using system.web.ui.webcontrols; namespace webapplication1 { public partial class webform1 : system.web.ui.page { protected void page_load(object sender, eventargs e) { string cs = "data source=.;initial catalog=test;integrated security=sspi"; sqlconnection con = new sqlconnection(cs); sqlcommand comma = new sqlcommand("select * try", con); con.open(); gridview1.datasource = comma.executereader(); gridview1.databind(); con.close(); } } }
the issue connection string using.
data source=.;initial catalog=test;integrated security=sspi
check sql server instance name running on local.
data source=**.\yourinstancename**;initial catalog=test;integrated security=sspi
you can test connection string validity trying add connection in server explorer (tools -> connect server - vs2015).
good luck
Comments
Post a Comment