I would like to create a simple registration form for WINDOWS application. I am using SQLite database which can be embedded into the project as I need to create a .exe file and mail it to my friend.
Now my registration form has 2 text boxes.
textBox1 for name
textBox2 for password
I need to insert these 2 values into the table and I have written the following code.
using Finisar.SQLite;
namespace Task_Sa
{
public partial class Form2 : Form {
    string connectionString;
    public Form2()
    {
        InitializeComponent();
        connectionString = @"Data Source=database.db;Version=3;New=True;Compress=True;";
    }
    private void button1_Click(object sender, EventArgs e)
    {
        using (SQLiteConnection sqlite_conn = new SQLiteConnection(connectionString))
           {
               SQLiteCommand cmd = new SQLiteCommand();
               cmd.CommandText = @"INSERT INTO TaskTable(UserName,PassWord) values(@userName,@passWord)";
               cmd.Connection = sqlite_conn;
               cmd.Parameters.Add(new SQLiteParameter("@userName",textBox1.Text));  -> ERROR
here I am getting the error as the parameters are not matching. 2 parameters should be of type string and dbType. Please help me to complete the code in this regard. I have copied and pasted SQLite dll file in debug folder of my project and I also have used the " using Finisar.SQLite; " name space.
           }
    }
}
}
 
Aucun commentaire:
Enregistrer un commentaire