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
1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) at
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) at
1 retry, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
1
retry) at
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
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
1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) at
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) at
1 retry, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
1
retry) at
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
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
1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) at
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) at
1 retry, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
1
retry) at
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
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
add a comment |
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
1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) at
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) at
1 retry, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
1
retry) at
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
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
1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) at
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) at
1 retry, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
1
retry) at
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
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
1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) at
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) at
1 retry, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
1
retry) at
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
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
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
add a comment |
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
1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) at
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) at
1 retry, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
1
retry) at
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
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
1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) at
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) at
1 retry, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
1
retry) at
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
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
1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) at
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) at
1 retry, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
1
retry) at
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
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
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
1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) at
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) at
1 retry, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
1
retry) at
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
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
1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) at
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) at
1 retry, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
1
retry) at
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
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
1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) at
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) at
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) at
1 retry, DbConnectionOptions userOptions) at
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
1
retry) at
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource
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
asp.net web-services
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
add a comment |
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
add a comment |
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.
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
add a comment |
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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