hi
I'm trying to execute a stored procedure which returns a datatable
my code is:
try {
string conStr = WebConfigurationManager.ConnectionStrings[0].ConnectionString;
SqlDataAdapter adapter;
DataTable ans = new DataTable();
SqlConnection connection = new SqlConnection(conStr);
SqlCommand command = new SqlCommand();
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "usp_GetUserDetails";
command.Parameters.Add("@UserName", SqlDbType.VarChar);
command.Parameters.Add("@Password", SqlDbType.VarChar);
command.Parameters["@UserName"].Value = user;
command.Parameters["@UserName"].Direction = ParameterDirection.Input;
command.Parameters["@Password"].Value = pass;
command.Parameters["@Password"].Direction = ParameterDirection.Input;
adapter = new SqlDataAdapter(command.CommandText, connection);
adapter.Fill(ans);
return ans;
}
catch (Exception ex)
{
throw ex;
}
when i execute i get an exception:
An attempt to attach an auto-named database for file C:\Documents and
Settings\Administrator\My Documents\Visual Studio
2008\WebSites\WebSite1\App_Data\aspnetdb.mdf failed. A database with
the same name exists, or specified file cannot be Opened, or it is
located on UNC share.
the connection string is:
<add name="MainConnectionString" connectionString="Data Source=MIKLAT\SQLEXPRESS;Initial Catalog=...;Integrated Security=True; providerName="System.Data.SqlClient"/>
I'm not running this site from iis, just from
visual studio 2008.
the database is located in c:\program files\sql 2005 ....
i tried to look for a solution but didnt find something helpfull.