Object reference not set to an instance of an object, on
SqlConnection.Open(), asp.net
just learning asp.net with c# and my code is throwing this exception when
im trying to open a connection to my database:
string connectionString
="DataSource=localhost,3306;Database=somedatabase;Uid=username;Pwd=password;";
using(SqlConnection con = new SqlConnection(connectionString))
{
con.Open(); // Exception Thrown Here
}
Seems relatively simple, so ive really no clue why this is happening.
one other thing;
all this code is inside tags on the webpage (not really sure if that makes
any difference, quite new to asp.net)
Cheers!
No comments:
Post a Comment