Hi I am trying to insert two different values name and comment in my table but I am getting an error. I have a button and when it is clicked I want the values to be stored in the database,I would like to mention that I am quite new to sql and I am just experimenting. Is there any possible way to insert 2 values in 2 different rows ? if so how ? Here is my try. many thanks.
public void onClick(View v)
{
mydb.execSQL("insert into test (name) values(?);",new String[]
{name.getText().toString()});
mydb.execSQL("insert into test (comment) values(?);",new String[]
{comment.getText().toString()});
Toast.makeText(getApplicationContext(), "DATA INSERTED", 3000).show();
}
});
this is my create table statement.
mydb.execSQL("CREATE TABLE IF NOT EXISTS test (id INTEGER PRIMARY KEY AUTOINCREMENT,name
varchar,comment varchar);");
This seems that is not working though.Any advice guys ?