0
현재 진행중인 프로젝트의 경우, 데이터를 저장할 서버가 다운로드 된 Access 데이터베이스를 사용하고 있습니다. 일단 파일이 다운로드되면 데이터베이스를 열고 데이터 세트로 복사하여 데이터 편집을 더 쉽게 만듭니다.다중 테이블로 데이터 셋 저장하기
내가 지금 가지고있는 문제는 데이터 집합을 다시 액세스 데이터베이스에 저장해야한다는 것입니다. 그러나 프로그램 실행 중에 데이터 집합에도 새 열을 추가했습니다. 따라서 액세스 데이터베이스를 업데이트 할 수있는 방법이 있습니다. 새 데이터 및 열로 다운로드 한 후 E : \ 드라이브에 저장되거나 처음부터 새 데이터베이스를 만들어야합니다.
코드 나 데이터 집합을로드하고 복사하는 데 사용 당신이 그리워하는 것은 SqlDataReader 개체입니다
private void accessConnect()
{
//Assign values to access database variables
Connection = new OleDbConnection();
command = new OleDbCommand();
adapter = new OleDbDataAdapter();
databaseDataSet = new DataSet();
//Assign location of database to connection variable
connection.ConnectionString =
@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\EAttendance.accdb;" +
"Persist Security Info=False";
//Establish connection with database
command.Connection = connection;
//Copy all tables into a c# dataset
try
{
//Select the user table in the database
command.CommandText = "SELECT * FROM users";
adapter.SelectCommand = command;
//Copy table into dataset
adapter.Fill(databaseDataSet,"users");
//Select the students table in the database
command.CommandText = "SELECT * FROM students";
adapter.SelectCommand = command;
//copy the students database into the dataset
adapter.Fill(databaseDataSet, "students");
}
//catch exception and display error if application fails to read database
catch (OleDbException)
{
//Display error in form title bar
this.Text = "Error #102 : Database Read Error";
// Set connection value to false
connectionBoolean = false;
}
}
그런 다음에 그 열을 다시 할 필요는 데이터 집합의 테이블에 새 열을 추가하는 경우 액세스 파일. 데이터 집합을 저장해도 Access 파일에 새 열이 만들어지지 않습니다. 기존 스키마를 변경할 수있는 명령이 있습니다. [여기를 참조하십시오] (http://msdn.microsoft.com/en-us/library/dn123881.aspx) – Steve