Quantcast
Channel: Microsoft SQL Server
Viewing all articles
Browse latest Browse all 4871

SQL Access Denied wjen connecting from VS

$
0
0

I have set up a database (QCDB) in my SQLEXPRESS instance. I have added a user (QCast) with serveradmin, sysadmin, and public server roles enabled at the server level. The user has db_owner role at the db level. But when connecting to the db with the below command in VS

string strConn = "Data Source=STA15-DT-ADM\\SQLEXPRESS;AttachDbFilename=C\\Program Files\\Microsoft SQL Server\\MSSQL14.SQLEXPRESS\\MSSQL\\DATA\\QCDB.mdf;User Id=QCast;Password=QC@st;Connect Timeout=30";


SqlConnection con = new SqlConnection(strConn);
string dbget = "SELECT WOnum WOstatus FROM WOdetail";
SqlCommand cmd = new SqlCommand(dbget, con);
con.Open();
SqlDataAdapter ad = new SqlDataAdapter(cmd);
DataTable dt = new DataTable("Results");
ad.Fill(dt);
WOgrid.ItemsSource = dt.DefaultView;
cmd.Dispose();
con.Close();...


Viewing all articles
Browse latest Browse all 4871

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>