이제이 문제를 해결하려고합니다. 하지만 왜 작동하지 않았는지 모르겠습니다.C에서 sqlite db 파일을 업데이트하려고합니다. #
datagridview 양식의 데이터 변경이 끝났지 만 데스크톱의 sqlite 파일은 변경되지 않았습니다. 저를 가르 칠 수있는 사람은
namespace Ex1
{
public partial class Form1 : Form
{
int initValue = 0;
String chkString;
SQLiteConnection conn = new SQLiteConnection("Data Source=I:\\Coding\\VS\\Study1\\Ex1\\Ex1\\Test.db;Version=3;");
SQLiteDataAdapter adapter = null;
BindingSource bsOrigin = null;
DataSet ds = null;
Random rand = new Random();
KnownColor[] Colors = (KnownColor[])Enum.GetValues(typeof(KnownColor));
KnownColor randColor;
public Form1()
{
InitializeComponent();
textBox1.Text = initValue.ToString();
}
private void Form1_Load(object sender, EventArgs e)
{
bsOrigin = new BindingSource();
ds = GetData();
bsOrigin.DataSource = ds.Tables[0];
dataGridView1.DataSource = bsOrigin;
}
private DataSet GetData()
{
adapter = new SQLiteDataAdapter("SELECT * from Skill", conn);
DataSet ds = new DataSet();
adapter.Fill(ds);
return ds;
}
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
adapter = new SQLiteDataAdapter("SELECT * from Skill", conn);
BindingSource bs = (BindingSource)dataGridView1.DataSource;
DataTable dt = bs.DataSource as DataTable;
adapter.Update(dt);
}
}
}
있습니까?
'adapter.UpdateCommand'에 sql 텍스트를 지정해야합니다. 이제'SelectCommand' 텍스트 만 있습니다. –
업데이트 명령에 데이터 수정을위한 지침이 필요하다는 의미입니까? –
예, UPDATE Skill ...이됩니다. –