1
내 C# 코드가 기존 데이터베이스를 사용하는 대신 완전히 새로운 데이터베이스를 만드는 문제가 발생했습니다. 그런 다음 내 프로그램은 코드 자체가 새 테이블을보고 있기 때문에 기존 데이터베이스에 테이블이 있어도 프로그램이 정보를 삽입 할 테이블을 찾을 수없는 오류로 실행됩니다. 여기 내 코드는 다음과 같습니다.기존 데이터베이스 (SQLite 데이터베이스)에서 C# 쿼리를 사용하려면 어떻게해야합니까?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Finisar.SQLite;
namespace WestSlope
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SQLiteConnection sqlite_conn;
SQLiteCommand sqlite_cmd;
//SQLiteDataAdapter sqlite_datareader;
sqlite_conn = new SQLiteConnection("DataSource=ClientLogDB.db;Version=3;New=True;Compress=True;");
//open conection
sqlite_conn.Open();
//create sql commands
sqlite_cmd = sqlite_conn.CreateCommand();
//Let SQLite command know query is known
sqlite_cmd.CommandText = "INSERT INTO ASAM (ASAMone, ASAMtwo, ASAMthree, ASAMfour, ASAMLim, ASAMLimEX) VALUES ('Had to call', 'Reffered', 'Had to call', 'Watched', 1 , 'Injured legs');"
;
//execute query
sqlite_cmd.ExecuteNonQuery();
sqlite_conn.Close();
}
}
}
코드는 사용자가 버튼을 누르면 프로그램이 기존 데이터베이스에 정보를 저장합니다. 그러나 볼 수 있듯이이 프로그램은 기존 데이터베이스를 사용하는 대신 새 데이터베이스를 만들고 있습니다.