2013-09-10 2 views
0

전 완전히 새로운 것입니다. 나는 책을 읽고 내 자기 C#을 가르치고있다. HEAD FIRST 서적 중 하나를 읽고 있습니다. 방금 연락처 데이터베이스 프로그램을 만들었습니다. 나는 SQL 데이터베이스를 폼에 배치하여 모든 단계를 수행했습니다. 프로그램을 실행하면이 뷰 소스가 인쇄됩니까?SQL Server CE 데이터베이스 업그레이드 3.5에서 4.0 C#

using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Linq; 
using System.Text; 
using System.Windows.Forms; 

namespace WindowsFormsApplication1 { 
    public partial class Form1 : Form { 
     public Form1() { 
      InitializeComponent(); 
     } 

     private void pictureBox1_Click(object sender, EventArgs e) { 
      MessageBox.Show("Contact List 1.0. \nWritten by: Greg Amero", "About"); 
     } 

     private void peopleBindingNavigatorSaveItem_Click(object sender, EventArgs e) { 
      this.Validate(); 
      this.peopleBindingSource.EndEdit(); 
      this.tableAdapterManager.UpdateAll(this.contactDBDataSet); 
     } 

     private void Form1_Load(object sender, EventArgs e) { 
      // TODO: This line of code loads data into the 'contactDBDataSet.People' table. You can move, or remove it, as needed. 
      this.peopleTableAdapter.Fill(this.contactDBDataSet.People); 
     } 
    } 
} 

this.peopleTableAdapter.Fill(this.contactDBDataSet.People);에 나는

SqlCelnvaliddatabase 형식의 예외가 처리되지 않은 이라며 오류 MSG를 얻을.
데이터베이스 파일은 이전 버전의 SQL Server Compact에서 만들어졌습니다. SqlCeEngine.Upgrade() 메서드를 사용하여 업그레이드하십시오. I 2012은 잘 작동하고 나는 그들이 떨어져 실행하는 SQL 서버 CE 버전과 함께 할 수있는 뭔가가 생각하고 표현하는 비주얼 사용하는 경우 나 시각 2010

를 사용하여 위의 오류가 발생합니다. 나는 등 SQL 서버 CE 3.5, 4.0, 설치되어 있지만 여전히 작동하지했습니다 .. 도와주세요 ..

그렉에게

+1

당신은 ** 비주얼 2012 익스프레스에서 작동한다고 말했습니까 ** 어떤 ** 버전에서 작동하지 않습니까? –

+0

버전 2010 죄송합니다. 추가하지 않았습니다. – user160605

답변

0

사용 4.0 SQL 서버 컴팩트 버전 3.5 파일을 업그레이드하는 코드를 다음과 같습니다.

public static void Upgrade(string fileName, string password) 
{ 
    if (String.IsNullOrEmpty(fileName) || password == null) 
     throw new Exception("Unable to create connection string because filename or password was not defined"); 

    try 
    { 
     var connectionString = string.Format(@"Data source={0};Password={1}", fileName, password); 
     var engine = new SqlCeEngine(connectionString); 
     engine.Upgrade(); 
    } 
    catch (Exception ex) 
    { 
     throw (ex); 
    } 
} 
관련 문제