I get errors when returned data from the method using web services references











up vote
0
down vote

favorite












I write my web services (asmx) as



[WebMethod]
//public List<Ahlam> GetBloodGroup(String gblood)
public DataSet GetBloodGroup(string gblood)
{
string bloodgroup = gblood.ToString();
string ApoloConn = ConfigurationManager.ConnectionStrings["ConnSApolo"].ConnectionString;

SqlConnection con = new SqlConnection(ApoloConn);

SqlCommand cmd = new SqlCommand("select name as 'NAME', blood_group as 'BLOOD GROUP', gender as 'GENDER' , city as 'CITY' , mobile as 'MOBILE' " +
"from dontable where blood_group = @bloodgroup", con);
cmd.Parameters.AddWithValue("@bloodgroup", bloodgroup);
SqlDataAdapter da = new SqlDataAdapter();

da.SelectCommand = cmd;
DataSet ds1 = new DataSet();
da.Fill(ds1);

return ds1;
}


And this is the buttonAction when it's pressed to call the function in my web service



protected void search_bloodgroup_Click(object sender, EventArgs e)
{
string bg = bloodlist.SelectedItem.Text;
AhlamQueryGroup.AhlamQueryBloodSoapClient client = new
AhlamQueryGroup.AhlamQueryBloodSoapClient();

DataSet set = client.GetBloodGroup(bg);
gridview_Donate.DataSource = set;
}


This is in the web.config of my project



<connectionStrings>
<add name="ConnSApolo"
connectionString="Data Source=(LocalDB)MSSQLLocalDB;AttachDbFilename=|DataDirectory|ApoloDB.mdf;Integrated Security=True;"
providerName="System.Data.SqlClient" />
</connectionStrings>


And this is the web.config in my web services project



<connectionStrings>
<add name="ConnSApolo"
connectionString="Data Source=(LocalDB)MSSQLLocalDB;AttachDbFilename=|DataDirectory|ApoloDB.mdf;Integrated Security=True;"
providerName="System.Data.SqlClient" />
</connectionStrings>


When I press the button I get this error




System.Web.Services.Protocols.SoapException: Server was unable to process request.



System.Data.SqlClient.SqlException: An attempt to attach an auto-named database for file E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesApp_DataApoloDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.



at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, BooleanapplyTransientFaultHandling)

at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)

at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)

at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)

at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)

at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, TaskCompletionSource1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource
1 retry, DbConnectionOptions
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) at
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource
1 retry, DbConnectionOptions userOptions) at
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
retry) at
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
1
retry) at System.Data.SqlClient.SqlConnection.Open() at
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) at
WebServices.AhlamQueryBlood.GetBloodGroup(String gblood) in
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesAhlamQueryBlood.asmx.cs:line
40 --- End of inner exception stack trace --- Description: An
unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the
error and where it originated in the code.



Exception Details: System.ServiceModel.FaultException:
System.Web.Services.Protocols.SoapException: Server was unable to
process request. ---> System.Data.SqlClient.SqlException: An attempt
to attach an auto-named database for file
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesApp_DataApoloDB.mdf
failed. A database with the same name exists, or specified file cannot
be opened, or it is located on UNC share. at
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
identity, SqlConnectionString connectionOptions, SqlCredential
credential, Object providerInfo, String newPassword, SecureString
newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString
userConnectionOptions, SessionData reconnectSessionData,
DbConnectionPool pool, String accessToken, Boolean
applyTransientFaultHandling) at
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo,
DbConnectionPool pool, DbConnection owningConnection,
DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool
pool, DbConnection owningObject, DbConnectionOptions options,
DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection
owningObject, DbConnectionOptions userOptions, DbConnectionInternal
oldConnection) at
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection
owningObject, DbConnectionOptions userOptions, DbConnectionInternal
oldConnection) at
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean
allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, TaskCompletionSource1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource
1 retry, DbConnectionOptions
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) at
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource
1 retry, DbConnectionOptions userOptions) at
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
retry) at
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
1
retry) at System.Data.SqlClient.SqlConnection.Open() at
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) at
WebServices.AhlamQueryBlood.GetBloodGroup(String gblood) in
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesAhlamQueryBlood.asmx.cs:line
40 --- End of inner exception stack trace ---



Source Error:



Line 53: Line 54: public System.Data.DataSet
GetBloodGroup(string gblood) { Line 55: return
base.Channel.GetBloodGroup(gblood); Line 56: } Line 57:



Source File:
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectBloodBankBloodBankConnected
ServicesAhlamQueryGroupReference.cs Line: 55



Stack Trace:



[FaultException: System.Web.Services.Protocols.SoapException: Server
was unable to process request. --->
System.Data.SqlClient.SqlException: An attempt to attach an auto-named
database for file
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesApp_DataApoloDB.mdf
failed. A database with the same name exists, or specified file cannot
be opened, or it is located on UNC share. at
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
identity, SqlConnectionString connectionOptions, SqlCredential
credential, Object providerInfo, String newPassword, SecureString
newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString
userConnectionOptions, SessionData reconnectSessionData,
DbConnectionPool pool, String accessToken, Boolean
applyTransientFaultHandling) at
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo,
DbConnectionPool pool, DbConnection owningConnection,
DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool
pool, DbConnection owningObject, DbConnectionOptions options,
DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection
owningObject, DbConnectionOptions userOptions, DbConnectionInternal
oldConnection) at
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection
owningObject, DbConnectionOptions userOptions, DbConnectionInternal
oldConnection) at
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean
allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, TaskCompletionSource1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource
1 retry, DbConnectionOptions
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) at
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource
1 retry, DbConnectionOptions userOptions) at
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
retry) at
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
1
retry) at System.Data.SqlClient.SqlConnection.Open() at
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) at
WebServices.AhlamQueryBlood.GetBloodGroup(String gblood) in
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesAhlamQueryBlood.asmx.cs:line
40 --- End of inner exception stack trace ---]

System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg) +153

System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type) +336

BloodBank.AhlamQueryGroup.AhlamQueryBloodSoap.GetBloodGroup(String
gblood) +0

BloodBank.AhlamQueryGroup.AhlamQueryBloodSoapClient.GetBloodGroup(String
gblood) in
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectBloodBankBloodBankConnected
ServicesAhlamQueryGroupReference.cs:55

BloodBank.FilterDonor.search_bloodgroup_Click(Object sender, EventArgs
e) in
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectBloodBankBloodBankFilterDonor.aspx.cs:40
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9669714

System.Web.UI.WebControls.Button.RaisePostBackEvent(String
eventArgument) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +12

System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +15

System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+35 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+3562at




this is the reference of my webreferences in the my project
enter image description here
this is the web services in the webservices project in the same solution
enter image description here



I tried to remove connectionString from web.config in my webservices project but I get another error
enter image description here
when I press continue I get the same first error










share|improve this question
























  • Please edit your question and paste the full stacktrace of the exceptions as text, not as images (screenshots)
    – Rui Jarimba
    Nov 7 at 20:24















up vote
0
down vote

favorite












I write my web services (asmx) as



[WebMethod]
//public List<Ahlam> GetBloodGroup(String gblood)
public DataSet GetBloodGroup(string gblood)
{
string bloodgroup = gblood.ToString();
string ApoloConn = ConfigurationManager.ConnectionStrings["ConnSApolo"].ConnectionString;

SqlConnection con = new SqlConnection(ApoloConn);

SqlCommand cmd = new SqlCommand("select name as 'NAME', blood_group as 'BLOOD GROUP', gender as 'GENDER' , city as 'CITY' , mobile as 'MOBILE' " +
"from dontable where blood_group = @bloodgroup", con);
cmd.Parameters.AddWithValue("@bloodgroup", bloodgroup);
SqlDataAdapter da = new SqlDataAdapter();

da.SelectCommand = cmd;
DataSet ds1 = new DataSet();
da.Fill(ds1);

return ds1;
}


And this is the buttonAction when it's pressed to call the function in my web service



protected void search_bloodgroup_Click(object sender, EventArgs e)
{
string bg = bloodlist.SelectedItem.Text;
AhlamQueryGroup.AhlamQueryBloodSoapClient client = new
AhlamQueryGroup.AhlamQueryBloodSoapClient();

DataSet set = client.GetBloodGroup(bg);
gridview_Donate.DataSource = set;
}


This is in the web.config of my project



<connectionStrings>
<add name="ConnSApolo"
connectionString="Data Source=(LocalDB)MSSQLLocalDB;AttachDbFilename=|DataDirectory|ApoloDB.mdf;Integrated Security=True;"
providerName="System.Data.SqlClient" />
</connectionStrings>


And this is the web.config in my web services project



<connectionStrings>
<add name="ConnSApolo"
connectionString="Data Source=(LocalDB)MSSQLLocalDB;AttachDbFilename=|DataDirectory|ApoloDB.mdf;Integrated Security=True;"
providerName="System.Data.SqlClient" />
</connectionStrings>


When I press the button I get this error




System.Web.Services.Protocols.SoapException: Server was unable to process request.



System.Data.SqlClient.SqlException: An attempt to attach an auto-named database for file E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesApp_DataApoloDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.



at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, BooleanapplyTransientFaultHandling)

at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)

at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)

at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)

at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)

at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, TaskCompletionSource1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource
1 retry, DbConnectionOptions
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) at
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource
1 retry, DbConnectionOptions userOptions) at
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
retry) at
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
1
retry) at System.Data.SqlClient.SqlConnection.Open() at
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) at
WebServices.AhlamQueryBlood.GetBloodGroup(String gblood) in
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesAhlamQueryBlood.asmx.cs:line
40 --- End of inner exception stack trace --- Description: An
unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the
error and where it originated in the code.



Exception Details: System.ServiceModel.FaultException:
System.Web.Services.Protocols.SoapException: Server was unable to
process request. ---> System.Data.SqlClient.SqlException: An attempt
to attach an auto-named database for file
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesApp_DataApoloDB.mdf
failed. A database with the same name exists, or specified file cannot
be opened, or it is located on UNC share. at
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
identity, SqlConnectionString connectionOptions, SqlCredential
credential, Object providerInfo, String newPassword, SecureString
newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString
userConnectionOptions, SessionData reconnectSessionData,
DbConnectionPool pool, String accessToken, Boolean
applyTransientFaultHandling) at
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo,
DbConnectionPool pool, DbConnection owningConnection,
DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool
pool, DbConnection owningObject, DbConnectionOptions options,
DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection
owningObject, DbConnectionOptions userOptions, DbConnectionInternal
oldConnection) at
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection
owningObject, DbConnectionOptions userOptions, DbConnectionInternal
oldConnection) at
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean
allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, TaskCompletionSource1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource
1 retry, DbConnectionOptions
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) at
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource
1 retry, DbConnectionOptions userOptions) at
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
retry) at
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
1
retry) at System.Data.SqlClient.SqlConnection.Open() at
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) at
WebServices.AhlamQueryBlood.GetBloodGroup(String gblood) in
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesAhlamQueryBlood.asmx.cs:line
40 --- End of inner exception stack trace ---



Source Error:



Line 53: Line 54: public System.Data.DataSet
GetBloodGroup(string gblood) { Line 55: return
base.Channel.GetBloodGroup(gblood); Line 56: } Line 57:



Source File:
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectBloodBankBloodBankConnected
ServicesAhlamQueryGroupReference.cs Line: 55



Stack Trace:



[FaultException: System.Web.Services.Protocols.SoapException: Server
was unable to process request. --->
System.Data.SqlClient.SqlException: An attempt to attach an auto-named
database for file
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesApp_DataApoloDB.mdf
failed. A database with the same name exists, or specified file cannot
be opened, or it is located on UNC share. at
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
identity, SqlConnectionString connectionOptions, SqlCredential
credential, Object providerInfo, String newPassword, SecureString
newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString
userConnectionOptions, SessionData reconnectSessionData,
DbConnectionPool pool, String accessToken, Boolean
applyTransientFaultHandling) at
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo,
DbConnectionPool pool, DbConnection owningConnection,
DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool
pool, DbConnection owningObject, DbConnectionOptions options,
DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection
owningObject, DbConnectionOptions userOptions, DbConnectionInternal
oldConnection) at
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection
owningObject, DbConnectionOptions userOptions, DbConnectionInternal
oldConnection) at
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean
allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, TaskCompletionSource1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource
1 retry, DbConnectionOptions
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) at
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource
1 retry, DbConnectionOptions userOptions) at
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
retry) at
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
1
retry) at System.Data.SqlClient.SqlConnection.Open() at
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) at
WebServices.AhlamQueryBlood.GetBloodGroup(String gblood) in
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesAhlamQueryBlood.asmx.cs:line
40 --- End of inner exception stack trace ---]

System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg) +153

System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type) +336

BloodBank.AhlamQueryGroup.AhlamQueryBloodSoap.GetBloodGroup(String
gblood) +0

BloodBank.AhlamQueryGroup.AhlamQueryBloodSoapClient.GetBloodGroup(String
gblood) in
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectBloodBankBloodBankConnected
ServicesAhlamQueryGroupReference.cs:55

BloodBank.FilterDonor.search_bloodgroup_Click(Object sender, EventArgs
e) in
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectBloodBankBloodBankFilterDonor.aspx.cs:40
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9669714

System.Web.UI.WebControls.Button.RaisePostBackEvent(String
eventArgument) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +12

System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +15

System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+35 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+3562at




this is the reference of my webreferences in the my project
enter image description here
this is the web services in the webservices project in the same solution
enter image description here



I tried to remove connectionString from web.config in my webservices project but I get another error
enter image description here
when I press continue I get the same first error










share|improve this question
























  • Please edit your question and paste the full stacktrace of the exceptions as text, not as images (screenshots)
    – Rui Jarimba
    Nov 7 at 20:24













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I write my web services (asmx) as



[WebMethod]
//public List<Ahlam> GetBloodGroup(String gblood)
public DataSet GetBloodGroup(string gblood)
{
string bloodgroup = gblood.ToString();
string ApoloConn = ConfigurationManager.ConnectionStrings["ConnSApolo"].ConnectionString;

SqlConnection con = new SqlConnection(ApoloConn);

SqlCommand cmd = new SqlCommand("select name as 'NAME', blood_group as 'BLOOD GROUP', gender as 'GENDER' , city as 'CITY' , mobile as 'MOBILE' " +
"from dontable where blood_group = @bloodgroup", con);
cmd.Parameters.AddWithValue("@bloodgroup", bloodgroup);
SqlDataAdapter da = new SqlDataAdapter();

da.SelectCommand = cmd;
DataSet ds1 = new DataSet();
da.Fill(ds1);

return ds1;
}


And this is the buttonAction when it's pressed to call the function in my web service



protected void search_bloodgroup_Click(object sender, EventArgs e)
{
string bg = bloodlist.SelectedItem.Text;
AhlamQueryGroup.AhlamQueryBloodSoapClient client = new
AhlamQueryGroup.AhlamQueryBloodSoapClient();

DataSet set = client.GetBloodGroup(bg);
gridview_Donate.DataSource = set;
}


This is in the web.config of my project



<connectionStrings>
<add name="ConnSApolo"
connectionString="Data Source=(LocalDB)MSSQLLocalDB;AttachDbFilename=|DataDirectory|ApoloDB.mdf;Integrated Security=True;"
providerName="System.Data.SqlClient" />
</connectionStrings>


And this is the web.config in my web services project



<connectionStrings>
<add name="ConnSApolo"
connectionString="Data Source=(LocalDB)MSSQLLocalDB;AttachDbFilename=|DataDirectory|ApoloDB.mdf;Integrated Security=True;"
providerName="System.Data.SqlClient" />
</connectionStrings>


When I press the button I get this error




System.Web.Services.Protocols.SoapException: Server was unable to process request.



System.Data.SqlClient.SqlException: An attempt to attach an auto-named database for file E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesApp_DataApoloDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.



at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, BooleanapplyTransientFaultHandling)

at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)

at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)

at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)

at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)

at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, TaskCompletionSource1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource
1 retry, DbConnectionOptions
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) at
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource
1 retry, DbConnectionOptions userOptions) at
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
retry) at
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
1
retry) at System.Data.SqlClient.SqlConnection.Open() at
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) at
WebServices.AhlamQueryBlood.GetBloodGroup(String gblood) in
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesAhlamQueryBlood.asmx.cs:line
40 --- End of inner exception stack trace --- Description: An
unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the
error and where it originated in the code.



Exception Details: System.ServiceModel.FaultException:
System.Web.Services.Protocols.SoapException: Server was unable to
process request. ---> System.Data.SqlClient.SqlException: An attempt
to attach an auto-named database for file
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesApp_DataApoloDB.mdf
failed. A database with the same name exists, or specified file cannot
be opened, or it is located on UNC share. at
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
identity, SqlConnectionString connectionOptions, SqlCredential
credential, Object providerInfo, String newPassword, SecureString
newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString
userConnectionOptions, SessionData reconnectSessionData,
DbConnectionPool pool, String accessToken, Boolean
applyTransientFaultHandling) at
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo,
DbConnectionPool pool, DbConnection owningConnection,
DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool
pool, DbConnection owningObject, DbConnectionOptions options,
DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection
owningObject, DbConnectionOptions userOptions, DbConnectionInternal
oldConnection) at
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection
owningObject, DbConnectionOptions userOptions, DbConnectionInternal
oldConnection) at
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean
allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, TaskCompletionSource1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource
1 retry, DbConnectionOptions
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) at
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource
1 retry, DbConnectionOptions userOptions) at
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
retry) at
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
1
retry) at System.Data.SqlClient.SqlConnection.Open() at
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) at
WebServices.AhlamQueryBlood.GetBloodGroup(String gblood) in
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesAhlamQueryBlood.asmx.cs:line
40 --- End of inner exception stack trace ---



Source Error:



Line 53: Line 54: public System.Data.DataSet
GetBloodGroup(string gblood) { Line 55: return
base.Channel.GetBloodGroup(gblood); Line 56: } Line 57:



Source File:
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectBloodBankBloodBankConnected
ServicesAhlamQueryGroupReference.cs Line: 55



Stack Trace:



[FaultException: System.Web.Services.Protocols.SoapException: Server
was unable to process request. --->
System.Data.SqlClient.SqlException: An attempt to attach an auto-named
database for file
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesApp_DataApoloDB.mdf
failed. A database with the same name exists, or specified file cannot
be opened, or it is located on UNC share. at
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
identity, SqlConnectionString connectionOptions, SqlCredential
credential, Object providerInfo, String newPassword, SecureString
newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString
userConnectionOptions, SessionData reconnectSessionData,
DbConnectionPool pool, String accessToken, Boolean
applyTransientFaultHandling) at
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo,
DbConnectionPool pool, DbConnection owningConnection,
DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool
pool, DbConnection owningObject, DbConnectionOptions options,
DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection
owningObject, DbConnectionOptions userOptions, DbConnectionInternal
oldConnection) at
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection
owningObject, DbConnectionOptions userOptions, DbConnectionInternal
oldConnection) at
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean
allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, TaskCompletionSource1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource
1 retry, DbConnectionOptions
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) at
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource
1 retry, DbConnectionOptions userOptions) at
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
retry) at
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
1
retry) at System.Data.SqlClient.SqlConnection.Open() at
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) at
WebServices.AhlamQueryBlood.GetBloodGroup(String gblood) in
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesAhlamQueryBlood.asmx.cs:line
40 --- End of inner exception stack trace ---]

System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg) +153

System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type) +336

BloodBank.AhlamQueryGroup.AhlamQueryBloodSoap.GetBloodGroup(String
gblood) +0

BloodBank.AhlamQueryGroup.AhlamQueryBloodSoapClient.GetBloodGroup(String
gblood) in
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectBloodBankBloodBankConnected
ServicesAhlamQueryGroupReference.cs:55

BloodBank.FilterDonor.search_bloodgroup_Click(Object sender, EventArgs
e) in
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectBloodBankBloodBankFilterDonor.aspx.cs:40
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9669714

System.Web.UI.WebControls.Button.RaisePostBackEvent(String
eventArgument) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +12

System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +15

System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+35 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+3562at




this is the reference of my webreferences in the my project
enter image description here
this is the web services in the webservices project in the same solution
enter image description here



I tried to remove connectionString from web.config in my webservices project but I get another error
enter image description here
when I press continue I get the same first error










share|improve this question















I write my web services (asmx) as



[WebMethod]
//public List<Ahlam> GetBloodGroup(String gblood)
public DataSet GetBloodGroup(string gblood)
{
string bloodgroup = gblood.ToString();
string ApoloConn = ConfigurationManager.ConnectionStrings["ConnSApolo"].ConnectionString;

SqlConnection con = new SqlConnection(ApoloConn);

SqlCommand cmd = new SqlCommand("select name as 'NAME', blood_group as 'BLOOD GROUP', gender as 'GENDER' , city as 'CITY' , mobile as 'MOBILE' " +
"from dontable where blood_group = @bloodgroup", con);
cmd.Parameters.AddWithValue("@bloodgroup", bloodgroup);
SqlDataAdapter da = new SqlDataAdapter();

da.SelectCommand = cmd;
DataSet ds1 = new DataSet();
da.Fill(ds1);

return ds1;
}


And this is the buttonAction when it's pressed to call the function in my web service



protected void search_bloodgroup_Click(object sender, EventArgs e)
{
string bg = bloodlist.SelectedItem.Text;
AhlamQueryGroup.AhlamQueryBloodSoapClient client = new
AhlamQueryGroup.AhlamQueryBloodSoapClient();

DataSet set = client.GetBloodGroup(bg);
gridview_Donate.DataSource = set;
}


This is in the web.config of my project



<connectionStrings>
<add name="ConnSApolo"
connectionString="Data Source=(LocalDB)MSSQLLocalDB;AttachDbFilename=|DataDirectory|ApoloDB.mdf;Integrated Security=True;"
providerName="System.Data.SqlClient" />
</connectionStrings>


And this is the web.config in my web services project



<connectionStrings>
<add name="ConnSApolo"
connectionString="Data Source=(LocalDB)MSSQLLocalDB;AttachDbFilename=|DataDirectory|ApoloDB.mdf;Integrated Security=True;"
providerName="System.Data.SqlClient" />
</connectionStrings>


When I press the button I get this error




System.Web.Services.Protocols.SoapException: Server was unable to process request.



System.Data.SqlClient.SqlException: An attempt to attach an auto-named database for file E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesApp_DataApoloDB.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.



at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, BooleanapplyTransientFaultHandling)

at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)

at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)

at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)

at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)

at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, TaskCompletionSource1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource
1 retry, DbConnectionOptions
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) at
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource
1 retry, DbConnectionOptions userOptions) at
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
retry) at
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
1
retry) at System.Data.SqlClient.SqlConnection.Open() at
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) at
WebServices.AhlamQueryBlood.GetBloodGroup(String gblood) in
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesAhlamQueryBlood.asmx.cs:line
40 --- End of inner exception stack trace --- Description: An
unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the
error and where it originated in the code.



Exception Details: System.ServiceModel.FaultException:
System.Web.Services.Protocols.SoapException: Server was unable to
process request. ---> System.Data.SqlClient.SqlException: An attempt
to attach an auto-named database for file
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesApp_DataApoloDB.mdf
failed. A database with the same name exists, or specified file cannot
be opened, or it is located on UNC share. at
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
identity, SqlConnectionString connectionOptions, SqlCredential
credential, Object providerInfo, String newPassword, SecureString
newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString
userConnectionOptions, SessionData reconnectSessionData,
DbConnectionPool pool, String accessToken, Boolean
applyTransientFaultHandling) at
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo,
DbConnectionPool pool, DbConnection owningConnection,
DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool
pool, DbConnection owningObject, DbConnectionOptions options,
DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection
owningObject, DbConnectionOptions userOptions, DbConnectionInternal
oldConnection) at
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection
owningObject, DbConnectionOptions userOptions, DbConnectionInternal
oldConnection) at
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean
allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, TaskCompletionSource1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource
1 retry, DbConnectionOptions
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) at
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource
1 retry, DbConnectionOptions userOptions) at
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
retry) at
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
1
retry) at System.Data.SqlClient.SqlConnection.Open() at
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) at
WebServices.AhlamQueryBlood.GetBloodGroup(String gblood) in
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesAhlamQueryBlood.asmx.cs:line
40 --- End of inner exception stack trace ---



Source Error:



Line 53: Line 54: public System.Data.DataSet
GetBloodGroup(string gblood) { Line 55: return
base.Channel.GetBloodGroup(gblood); Line 56: } Line 57:



Source File:
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectBloodBankBloodBankConnected
ServicesAhlamQueryGroupReference.cs Line: 55



Stack Trace:



[FaultException: System.Web.Services.Protocols.SoapException: Server
was unable to process request. --->
System.Data.SqlClient.SqlException: An attempt to attach an auto-named
database for file
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesApp_DataApoloDB.mdf
failed. A database with the same name exists, or specified file cannot
be opened, or it is located on UNC share. at
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity
identity, SqlConnectionString connectionOptions, SqlCredential
credential, Object providerInfo, String newPassword, SecureString
newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString
userConnectionOptions, SessionData reconnectSessionData,
DbConnectionPool pool, String accessToken, Boolean
applyTransientFaultHandling) at
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions
options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo,
DbConnectionPool pool, DbConnection owningConnection,
DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool
pool, DbConnection owningObject, DbConnectionOptions options,
DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection
owningObject, DbConnectionOptions userOptions, DbConnectionInternal
oldConnection) at
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection
owningObject, DbConnectionOptions userOptions, DbConnectionInternal
oldConnection) at
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean
allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, TaskCompletionSource1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource
1 retry, DbConnectionOptions
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) at
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource
1 retry, DbConnectionOptions userOptions) at
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
retry) at
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
1
retry) at System.Data.SqlClient.SqlConnection.Open() at
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset,
DataTable datatables, Int32 startRecord, Int32 maxRecords, String
srcTable, IDbCommand command, CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior) at
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) at
WebServices.AhlamQueryBlood.GetBloodGroup(String gblood) in
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesAhlamQueryBlood.asmx.cs:line
40 --- End of inner exception stack trace ---]

System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg) +153

System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type) +336

BloodBank.AhlamQueryGroup.AhlamQueryBloodSoap.GetBloodGroup(String
gblood) +0

BloodBank.AhlamQueryGroup.AhlamQueryBloodSoapClient.GetBloodGroup(String
gblood) in
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectBloodBankBloodBankConnected
ServicesAhlamQueryGroupReference.cs:55

BloodBank.FilterDonor.search_bloodgroup_Click(Object sender, EventArgs
e) in
E:AhlamBloodHospital_projectBlood_Hospital_banks_projectBloodBankBloodBankFilterDonor.aspx.cs:40
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9669714

System.Web.UI.WebControls.Button.RaisePostBackEvent(String
eventArgument) +108

System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +12

System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +15

System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+35 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+3562at




this is the reference of my webreferences in the my project
enter image description here
this is the web services in the webservices project in the same solution
enter image description here



I tried to remove connectionString from web.config in my webservices project but I get another error
enter image description here
when I press continue I get the same first error







asp.net web-services






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 7 at 20:44









marc_s

566k12610931245




566k12610931245










asked Nov 7 at 20:23









AFB

53




53












  • Please edit your question and paste the full stacktrace of the exceptions as text, not as images (screenshots)
    – Rui Jarimba
    Nov 7 at 20:24


















  • Please edit your question and paste the full stacktrace of the exceptions as text, not as images (screenshots)
    – Rui Jarimba
    Nov 7 at 20:24
















Please edit your question and paste the full stacktrace of the exceptions as text, not as images (screenshots)
– Rui Jarimba
Nov 7 at 20:24




Please edit your question and paste the full stacktrace of the exceptions as text, not as images (screenshots)
– Rui Jarimba
Nov 7 at 20:24












1 Answer
1






active

oldest

votes

















up vote
0
down vote













To Simulate the issue:



First thing you have to do is..



Create new normal project (Not a web service project) then run your function if it is working or not.



public DataSet GetBloodGroup(string gblood)
{
string bloodgroup = gblood.ToString();
string ApoloConn = ConfigurationManager.ConnectionStrings["ConnSApolo"].ConnectionString;

SqlConnection con = new SqlConnection(ApoloConn);

SqlCommand cmd = new SqlCommand("select name as 'NAME', blood_group as 'BLOOD GROUP', gender as 'GENDER' , city as 'CITY' , mobile as 'MOBILE' " +
"from dontable where blood_group = @bloodgroup", con);
cmd.Parameters.AddWithValue("@bloodgroup", bloodgroup);
SqlDataAdapter da = new SqlDataAdapter();

da.SelectCommand = cmd;
DataSet ds1 = new DataSet();
da.Fill(ds1);

return ds1;
}


Something like:



DataSet dsSimulate = new DataSet();
dsSimulate = GetBloodGroup("YourbloodValueHere");


Then run it in debug mode to get and check the error.



Your error occur and it says (You already has a database name). Try to check if it is exists or not.



Reminder:



Before you do to use and run your Web Service, you have to make sure if it is working in Normal Debug mode.



There are possible two ways of problem.. It's either your function has an error or the deployment itself upon calling your Web Service.



when Adding Web Service into your project reference:



Web.Config File(Project Calling the Web Service)
It must look like this after you done adding the service reference deployed link at your project.



<client>
<endpoint address="http://localhost:1750/Service1.asmx" binding="basicHttpBinding"
bindingConfiguration="Service1Soap" contract="Service1.Service1Soap"
name="Service1Soap" />
<endpoint address="http://localhost:1750/Service1.asmx" binding="customBinding"
bindingConfiguration="Service1Soap12" contract="Service1.Service1Soap"
name="Service1Soap12" />
</client>


In you Code Behind:



 Service1.Service1SoapClient cli;

protected void Page_Load(object sender, EventArgs e)
{
cli = new Service1.Service1SoapClient("Service1Soap12");
cli.GetBloodGroup("BloodGourHere");//this line returns your DataSet
}


Hope it helps.






share|improve this answer























  • see, I did this and the function works. Also, I tried to make the web service with my project (in the same project without references) .. and it works..
    – AFB
    Nov 8 at 5:05












  • I want to make this web services separately and call its reference .. that is where I met the error.
    – AFB
    Nov 8 at 5:07










  • Try to check the folder permission of this..E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesApp_DataApoloDB.mdf
    – Vijunav Vastivch
    Nov 8 at 5:16










  • I don't know how can I check the permission {I use local database in the same project }..
    – AFB
    Nov 8 at 5:41











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53197259%2fi-get-errors-when-returned-data-from-the-method-using-web-services-references%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













To Simulate the issue:



First thing you have to do is..



Create new normal project (Not a web service project) then run your function if it is working or not.



public DataSet GetBloodGroup(string gblood)
{
string bloodgroup = gblood.ToString();
string ApoloConn = ConfigurationManager.ConnectionStrings["ConnSApolo"].ConnectionString;

SqlConnection con = new SqlConnection(ApoloConn);

SqlCommand cmd = new SqlCommand("select name as 'NAME', blood_group as 'BLOOD GROUP', gender as 'GENDER' , city as 'CITY' , mobile as 'MOBILE' " +
"from dontable where blood_group = @bloodgroup", con);
cmd.Parameters.AddWithValue("@bloodgroup", bloodgroup);
SqlDataAdapter da = new SqlDataAdapter();

da.SelectCommand = cmd;
DataSet ds1 = new DataSet();
da.Fill(ds1);

return ds1;
}


Something like:



DataSet dsSimulate = new DataSet();
dsSimulate = GetBloodGroup("YourbloodValueHere");


Then run it in debug mode to get and check the error.



Your error occur and it says (You already has a database name). Try to check if it is exists or not.



Reminder:



Before you do to use and run your Web Service, you have to make sure if it is working in Normal Debug mode.



There are possible two ways of problem.. It's either your function has an error or the deployment itself upon calling your Web Service.



when Adding Web Service into your project reference:



Web.Config File(Project Calling the Web Service)
It must look like this after you done adding the service reference deployed link at your project.



<client>
<endpoint address="http://localhost:1750/Service1.asmx" binding="basicHttpBinding"
bindingConfiguration="Service1Soap" contract="Service1.Service1Soap"
name="Service1Soap" />
<endpoint address="http://localhost:1750/Service1.asmx" binding="customBinding"
bindingConfiguration="Service1Soap12" contract="Service1.Service1Soap"
name="Service1Soap12" />
</client>


In you Code Behind:



 Service1.Service1SoapClient cli;

protected void Page_Load(object sender, EventArgs e)
{
cli = new Service1.Service1SoapClient("Service1Soap12");
cli.GetBloodGroup("BloodGourHere");//this line returns your DataSet
}


Hope it helps.






share|improve this answer























  • see, I did this and the function works. Also, I tried to make the web service with my project (in the same project without references) .. and it works..
    – AFB
    Nov 8 at 5:05












  • I want to make this web services separately and call its reference .. that is where I met the error.
    – AFB
    Nov 8 at 5:07










  • Try to check the folder permission of this..E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesApp_DataApoloDB.mdf
    – Vijunav Vastivch
    Nov 8 at 5:16










  • I don't know how can I check the permission {I use local database in the same project }..
    – AFB
    Nov 8 at 5:41















up vote
0
down vote













To Simulate the issue:



First thing you have to do is..



Create new normal project (Not a web service project) then run your function if it is working or not.



public DataSet GetBloodGroup(string gblood)
{
string bloodgroup = gblood.ToString();
string ApoloConn = ConfigurationManager.ConnectionStrings["ConnSApolo"].ConnectionString;

SqlConnection con = new SqlConnection(ApoloConn);

SqlCommand cmd = new SqlCommand("select name as 'NAME', blood_group as 'BLOOD GROUP', gender as 'GENDER' , city as 'CITY' , mobile as 'MOBILE' " +
"from dontable where blood_group = @bloodgroup", con);
cmd.Parameters.AddWithValue("@bloodgroup", bloodgroup);
SqlDataAdapter da = new SqlDataAdapter();

da.SelectCommand = cmd;
DataSet ds1 = new DataSet();
da.Fill(ds1);

return ds1;
}


Something like:



DataSet dsSimulate = new DataSet();
dsSimulate = GetBloodGroup("YourbloodValueHere");


Then run it in debug mode to get and check the error.



Your error occur and it says (You already has a database name). Try to check if it is exists or not.



Reminder:



Before you do to use and run your Web Service, you have to make sure if it is working in Normal Debug mode.



There are possible two ways of problem.. It's either your function has an error or the deployment itself upon calling your Web Service.



when Adding Web Service into your project reference:



Web.Config File(Project Calling the Web Service)
It must look like this after you done adding the service reference deployed link at your project.



<client>
<endpoint address="http://localhost:1750/Service1.asmx" binding="basicHttpBinding"
bindingConfiguration="Service1Soap" contract="Service1.Service1Soap"
name="Service1Soap" />
<endpoint address="http://localhost:1750/Service1.asmx" binding="customBinding"
bindingConfiguration="Service1Soap12" contract="Service1.Service1Soap"
name="Service1Soap12" />
</client>


In you Code Behind:



 Service1.Service1SoapClient cli;

protected void Page_Load(object sender, EventArgs e)
{
cli = new Service1.Service1SoapClient("Service1Soap12");
cli.GetBloodGroup("BloodGourHere");//this line returns your DataSet
}


Hope it helps.






share|improve this answer























  • see, I did this and the function works. Also, I tried to make the web service with my project (in the same project without references) .. and it works..
    – AFB
    Nov 8 at 5:05












  • I want to make this web services separately and call its reference .. that is where I met the error.
    – AFB
    Nov 8 at 5:07










  • Try to check the folder permission of this..E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesApp_DataApoloDB.mdf
    – Vijunav Vastivch
    Nov 8 at 5:16










  • I don't know how can I check the permission {I use local database in the same project }..
    – AFB
    Nov 8 at 5:41













up vote
0
down vote










up vote
0
down vote









To Simulate the issue:



First thing you have to do is..



Create new normal project (Not a web service project) then run your function if it is working or not.



public DataSet GetBloodGroup(string gblood)
{
string bloodgroup = gblood.ToString();
string ApoloConn = ConfigurationManager.ConnectionStrings["ConnSApolo"].ConnectionString;

SqlConnection con = new SqlConnection(ApoloConn);

SqlCommand cmd = new SqlCommand("select name as 'NAME', blood_group as 'BLOOD GROUP', gender as 'GENDER' , city as 'CITY' , mobile as 'MOBILE' " +
"from dontable where blood_group = @bloodgroup", con);
cmd.Parameters.AddWithValue("@bloodgroup", bloodgroup);
SqlDataAdapter da = new SqlDataAdapter();

da.SelectCommand = cmd;
DataSet ds1 = new DataSet();
da.Fill(ds1);

return ds1;
}


Something like:



DataSet dsSimulate = new DataSet();
dsSimulate = GetBloodGroup("YourbloodValueHere");


Then run it in debug mode to get and check the error.



Your error occur and it says (You already has a database name). Try to check if it is exists or not.



Reminder:



Before you do to use and run your Web Service, you have to make sure if it is working in Normal Debug mode.



There are possible two ways of problem.. It's either your function has an error or the deployment itself upon calling your Web Service.



when Adding Web Service into your project reference:



Web.Config File(Project Calling the Web Service)
It must look like this after you done adding the service reference deployed link at your project.



<client>
<endpoint address="http://localhost:1750/Service1.asmx" binding="basicHttpBinding"
bindingConfiguration="Service1Soap" contract="Service1.Service1Soap"
name="Service1Soap" />
<endpoint address="http://localhost:1750/Service1.asmx" binding="customBinding"
bindingConfiguration="Service1Soap12" contract="Service1.Service1Soap"
name="Service1Soap12" />
</client>


In you Code Behind:



 Service1.Service1SoapClient cli;

protected void Page_Load(object sender, EventArgs e)
{
cli = new Service1.Service1SoapClient("Service1Soap12");
cli.GetBloodGroup("BloodGourHere");//this line returns your DataSet
}


Hope it helps.






share|improve this answer














To Simulate the issue:



First thing you have to do is..



Create new normal project (Not a web service project) then run your function if it is working or not.



public DataSet GetBloodGroup(string gblood)
{
string bloodgroup = gblood.ToString();
string ApoloConn = ConfigurationManager.ConnectionStrings["ConnSApolo"].ConnectionString;

SqlConnection con = new SqlConnection(ApoloConn);

SqlCommand cmd = new SqlCommand("select name as 'NAME', blood_group as 'BLOOD GROUP', gender as 'GENDER' , city as 'CITY' , mobile as 'MOBILE' " +
"from dontable where blood_group = @bloodgroup", con);
cmd.Parameters.AddWithValue("@bloodgroup", bloodgroup);
SqlDataAdapter da = new SqlDataAdapter();

da.SelectCommand = cmd;
DataSet ds1 = new DataSet();
da.Fill(ds1);

return ds1;
}


Something like:



DataSet dsSimulate = new DataSet();
dsSimulate = GetBloodGroup("YourbloodValueHere");


Then run it in debug mode to get and check the error.



Your error occur and it says (You already has a database name). Try to check if it is exists or not.



Reminder:



Before you do to use and run your Web Service, you have to make sure if it is working in Normal Debug mode.



There are possible two ways of problem.. It's either your function has an error or the deployment itself upon calling your Web Service.



when Adding Web Service into your project reference:



Web.Config File(Project Calling the Web Service)
It must look like this after you done adding the service reference deployed link at your project.



<client>
<endpoint address="http://localhost:1750/Service1.asmx" binding="basicHttpBinding"
bindingConfiguration="Service1Soap" contract="Service1.Service1Soap"
name="Service1Soap" />
<endpoint address="http://localhost:1750/Service1.asmx" binding="customBinding"
bindingConfiguration="Service1Soap12" contract="Service1.Service1Soap"
name="Service1Soap12" />
</client>


In you Code Behind:



 Service1.Service1SoapClient cli;

protected void Page_Load(object sender, EventArgs e)
{
cli = new Service1.Service1SoapClient("Service1Soap12");
cli.GetBloodGroup("BloodGourHere");//this line returns your DataSet
}


Hope it helps.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 8 at 8:56

























answered Nov 8 at 0:57









Vijunav Vastivch

2,9011720




2,9011720












  • see, I did this and the function works. Also, I tried to make the web service with my project (in the same project without references) .. and it works..
    – AFB
    Nov 8 at 5:05












  • I want to make this web services separately and call its reference .. that is where I met the error.
    – AFB
    Nov 8 at 5:07










  • Try to check the folder permission of this..E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesApp_DataApoloDB.mdf
    – Vijunav Vastivch
    Nov 8 at 5:16










  • I don't know how can I check the permission {I use local database in the same project }..
    – AFB
    Nov 8 at 5:41


















  • see, I did this and the function works. Also, I tried to make the web service with my project (in the same project without references) .. and it works..
    – AFB
    Nov 8 at 5:05












  • I want to make this web services separately and call its reference .. that is where I met the error.
    – AFB
    Nov 8 at 5:07










  • Try to check the folder permission of this..E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesApp_DataApoloDB.mdf
    – Vijunav Vastivch
    Nov 8 at 5:16










  • I don't know how can I check the permission {I use local database in the same project }..
    – AFB
    Nov 8 at 5:41
















see, I did this and the function works. Also, I tried to make the web service with my project (in the same project without references) .. and it works..
– AFB
Nov 8 at 5:05






see, I did this and the function works. Also, I tried to make the web service with my project (in the same project without references) .. and it works..
– AFB
Nov 8 at 5:05














I want to make this web services separately and call its reference .. that is where I met the error.
– AFB
Nov 8 at 5:07




I want to make this web services separately and call its reference .. that is where I met the error.
– AFB
Nov 8 at 5:07












Try to check the folder permission of this..E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesApp_DataApoloDB.mdf
– Vijunav Vastivch
Nov 8 at 5:16




Try to check the folder permission of this..E:AhlamBloodHospital_projectBlood_Hospital_banks_projectWebServicesWebServicesApp_DataApoloDB.mdf
– Vijunav Vastivch
Nov 8 at 5:16












I don't know how can I check the permission {I use local database in the same project }..
– AFB
Nov 8 at 5:41




I don't know how can I check the permission {I use local database in the same project }..
– AFB
Nov 8 at 5:41


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53197259%2fi-get-errors-when-returned-data-from-the-method-using-web-services-references%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Hercules Kyvelos

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud