2012-11-06 6 views
0

SQL Server CE 로컬 데이터베이스 (*.sdf 파일)에 데이터를 입력하는 VB.NET 프로그램을 작성하고 있습니다.SQL Server Compact에 데이터 삽입

Imports System.Data.SqlClient 
    Public Class Form1 
    Dim myConnection As SqlConnection 
    Dim myCommand As SqlCommand 
    Dim ra As Integer 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 
     myConnection = New SqlConnection("Data Source= Database1.sdf") 
     myConnection.Open() 
     myCommand = New SqlCommand("Insert into website('"TextBox1.Text"')", myConnection) 
     ra = myCommand.ExecuteNonQuery() 
     MessageBox.Show("Updated") 
     myConnection.Close() 
    End Sub 

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
     TextBox1.Text = My.Settings.SaveWebsite 
    End Sub 
End Class 

내가 컴파일하는 동안 세 가지 오류를 얻을 :

오류 1 : 문자열로 공공 서브 뉴 (cmdText '의 매개 변수를'연결 '에 대해 지정되지 인수

내 코드는 이것이다 , 연결로 으로 System.Data.SqlClient.SqlConnection, 트랜잭션으로 System.Data.SqlClient.SqlTransaction) '.

오류 2
쉼표, ')'또는 유효한 표현식 계속이 필요합니다.

오류 3
'System.Data.SqlClient.SqlConnection'형식의 값을 'System.Data.SqlClient.SqlTransaction'으로 변환 할 수 없습니다.

이것은 처음 VB.NET을 사용하고 있으며 누군가 내가 잘못하고있는 것을 알기를 희망합니다. 사전에

감사

답변

0

음, 우선 : SQL 서버를 컴팩트 에디션합니다 (*.sdf 파일)을 대상으로 할 때, 당신은 SqlCeConnectionSqlCeCommand (안 SqlConnection 또는 SqlCommand를 사용할 필요가 - 본격적인위한 것들이다), 비 컴팩트 SQL 서버는

둘째

: 당신의 INSERT 문이 올바르지 않습니다 - 올바른 SQL 구문은 다음과 같습니다

INSERT INTO Table (col1, col2, ..., colN) 
VALUES(val1, val2, ..., valN) 
+1

SQLCe 연결이 문제였습니다. 엄청 고마워. –