Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Error in SQL pls Help!!!!

Author  Topic 

ahme09
Starting Member

6 Posts

Posted - 2007-08-16 : 21:35:10
i'm using WCF to cre8 a new web service but i have this problem in accessing to the database after i call for the method, anyone can help me???

this is the error:

"Failed to generate a user instance of SQL server due to a failure in starting the process for the user instance. the connection will be closed."

hey001us
Posting Yak Master

185 Posts

Posted - 2007-08-16 : 22:44:04
can you post your code?

hey
Go to Top of Page

ahme09
Starting Member

6 Posts

Posted - 2007-08-16 : 22:55:44
public CustomerInfo getCustomerInfo(string NRIC)
{
/*CustomerInfo info = new CustomerInfo();
info.FirstName = "ABCDEF";
info.LastName = "GHIJKL";
info.IC = "S123457A";
info.HandphoneNo = "987654321";
return (info);*/

//get connection string from web.config

string strConnectionString = ConfigurationManager.ConnectionStrings["SysticConnectionString"].ConnectionString;

//create connection
SqlConnection SysticConnect = new SqlConnection(strConnectionString);
SqlCommand CustCommand = new SqlCommand("SELECT NRIC, FirstName, LastName, HpNo FROM Customer WHERE NRIC=@NRICid", SysticConnect);

CustCommand.Parameters.AddWithValue("@NRICid", NRIC);
// open connection
SysticConnect.Open();

// reader returns result for matching ManfacturerID
SqlDataReader CustReader = CustCommand.ExecuteReader();

CustomerInfo Customer = new CustomerInfo();

while (CustReader.Read())
{
Customer.FirstName = System.Convert.ToString(CustReader["FirstName"]);
Customer.IC = System.Convert.ToString(CustReader["NRIC"]);
Customer.LastName = System.Convert.ToString(CustReader["LastName"]);
Customer.HandphoneNo = System.Convert.ToString(CustReader["HpNo"]);
}
CustReader.Close();
SysticConnect.Close();
return (Customer);
}
Go to Top of Page

ahme09
Starting Member

6 Posts

Posted - 2007-08-16 : 23:02:04
This code is using WWF to call the WCF coding above

private void TicketInfo_ExecuteCode(object sender, EventArgs e)
{
Console.Write("Ticket Available:");
Console.WriteLine("");
try
{
ConcertInfo info = new ConcertInfo();
TixServiceClient client = new TixServiceClient();
Console.Write("Enter Concert ID:");

string strConcertInfo = Console.ReadLine();

info = client.getConcertInfo(strConcertInfo);
retStatus = info.RetStatus;

if (info.RetStatus == true )
{
Console.Write("Concert ID:" + info.ConcertID.ToString());
Console.WriteLine("");
Console.Write("Concert Title:" + info.ConcertTitle.ToString());
Console.WriteLine("");
Console.Write("Concert Date: " + info.ConcertDate.ToString());
Console.WriteLine("");
Console.Write("Concert Venue: " + info.ConcertVenue.ToString());

}
else
{
Console.Write("No record found");

}

}
catch (Exception ex)
{

Console.Write(ex.Message.ToString());
}

Console.WriteLine("");
Go to Top of Page

hey001us
Posting Yak Master

185 Posts

Posted - 2007-08-16 : 23:14:21
your application and DB both in same server?, post your connection string as well?

hey
Go to Top of Page

ahme09
Starting Member

6 Posts

Posted - 2007-08-16 : 23:17:00
<connectionStrings>
<add name="SysticConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Sistic.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
Go to Top of Page

hey001us
Posting Yak Master

185 Posts

Posted - 2007-08-16 : 23:39:33
We should not discuss about c# coding here.
info = client.getConcertInfo(strConcertInfo);
is not like below?
getCustomerInfo(strConcertInfo)


hey
Go to Top of Page

ahme09
Starting Member

6 Posts

Posted - 2007-08-16 : 23:51:54
er... i don't understand what you trying to say.. can you explain?
Go to Top of Page
   

- Advertisement -