SQLExpress database file auto-creation error

B

Borek

Hello,
I am getting the beforementioned error when trying to populate DataSet
object with data taken from SQL2k database. Then I want to bind DataSet
to GridView control. But when I use SqlDataSource object to bind data
from the same database to the GridView everything is ok (using the same
connection string and SqlClient provider). And on top of that I don't
know why does this error refer to SQLExpress??? And it wants to create
an mdf file in App_Data...why?


Let me quote the whole error:

"SQLExpress database file auto-creation error:
The connection string specifies a local SQL Server Express instance
using a database location within the applications App_Data directory.
The provider attempted to automatically create the application services
database because the provider determined that the database does not
exist. The following configuration requirements are necessary to
successfully check for existence of the application services database
and automatically create the application services database:(...)"

And here's my connectionStrings section from web.config:

<add name="localConnectionString" connectionString="Data
Source=BOREK;Initial Catalog=electronic_driving_license_db;Integrated
Security=True"
providerName="System.Data.SqlClient"/>

And piece of code that is placed in separate class file located in
App_Code:

public class poCandidates
{
public DataSet dsCandidates;
public poCandidates()
{
dsCandidates = GetCandidatesAsTrainer();
}
private DataSet GetCandidatesAsTrainer()
{
string trainerID = HttpContext.Current.User.Identity.Name;
string strConnection =
ConfigurationManager.ConnectionStrings["localConnectionString"].ConnectionString;
SqlConnection myConnection = new SqlConnection(strConnection);
DataSet myDataSet = new DataSet();
SqlCommand myCommand;
SqlParameter myParameter;
try
{
myConnection.Open();
myCommand = new SqlCommand("spGetCandidatesAsTrainer",
myConnection);
myCommand.CommandType = CommandType.StoredProcedure;
myParameter =
myCommand.Parameters.AddWithValue("@trainerID", SqlDbType.VarChar);
myParameter.Value = trainerID;
SqlDataAdapter myAdapter = new SqlDataAdapter(myCommand);

myAdapter.Fill(myDataSet);

}
catch (Exception ex)
{

}

finally
{
myConnection.Close();
}
return myDataSet;
}
}
I am using Visual Web Developer 2005 Express Edition and ASP.NET 2.0.
I would appreciate any suggestions!
 
B

Borek

Sorry it isn't working with SqlDataSource either. I wrote this because
I only managed to perform a test while using the wizard. the test went
ok. But it still isnt working. As a matter of a fact the debugger
doesn't even hit the file in which I have my code. It crashes before it
gets to the file. I'm really confused.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top