lundi 9 février 2015

how to open SQLite connection in wcf

I have some WCF Code that accesses SQLite database, but when i want to open SQLite Connection an error occurred

error message: Fault Exception was Unhandled

error picture: Click to open error message picture


WCF Interface code:



[ServiceContract]
public interface IService1
{
[OperationContract]
string openConnection(string query);
}


WCF Interface Implementation code:



public class Service1 : IService1
{
public string openConnection(string query)
{
SQLiteConnection connection = new SQLiteConnection();
connection.ConnectionString = @"Data Source=C:\SqliteDBFile.sqlite;Version=3;";
try
{
connection.Open();
}
catch(FaultException f)
{
throw new FaultException("Error occurred");
}

return "OK";
}
}


Client Code:



private void button1_Click(object sender, EventArgs e)
{
ServiceReference1.Service1Client client = new ServiceRefrence1.Service1Client();
MessageBox.Show(client.openConnection("select * from users"));
}


Error occurred when client sent request to wcf service to open sqlite connection.

Where is my Wrong?

Please Help me!


Aucun commentaire:

Enregistrer un commentaire