vendredi 22 mai 2015

Using sqlite database in web service in c#

I am using sqlite database in c# web service but getting the error

SQL logic error or missing database no such table: Enrolment".

Below is my code:

public class Service1 : System.Web.Services.WebService
{
    SQLiteConnection sqlite;
    SQLiteCommand cmd;

    [WebMethod]
    public String enterToDb()
    {
        sqlite = new SQLiteConnection(@"Data Source=Master.db3");
        sqlite.Open();
        String query = "select * from Enrolment";//"create table PersonalDetails(Aadhaar text,Name text,Gender text,CarNumber text)";
        cmd = new SQLiteCommand(query, sqlite);
        SQLiteDataReader reader = cmd.ExecuteReader();
        String name="hhh";
        while (reader.Read())
        {
            String aad = reader["IdNo"].ToString();
             name = reader["Name"].ToString();
        }
        sqlite.Close();
        return name;
    }
}

The table is present in the database and If I use this code in normal windows application, it works fine but not with web service

Aucun commentaire:

Enregistrer un commentaire