 |
|
อยากให้ช่วยดูโค้ดหน่อยค่ะว่ามันผิดตรงไหน error มันขึ้นว่า Incorrect syntax near ','. ว่ามันใกล้กับตรงไหนค่ะขอบคุรค่ะ |
|
 |
|
|
 |
 |
|
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'------conect
Dim cn As New SqlConnection(strconn)
With cn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = cn.ConnectionString
cn.Open()
End With
Dim sql As String = ""
Select Case FlagAction
Case "Add"
sql = "insert into PET,TYPE,(Pet_ID,Name_PET,Type_Name,Bind,Sex)"
sql = sql & "values(@Pet_ID,@Name_Pet,@Type_Name,@Bind,@Sex)"
Case "Edit"
sql = (" update PET")
sql &= (" set Name_PET=@Name_PET,")
sql &= (" Type_Name=@Type_Name,")
sql &= (" Bind=@Bind,")
sql &= (" Sex=@Sex")
sql &= (" where (Pet_ID=@Pet_ID)")
End Select
Dim cm As New SqlCommand
With cm
.CommandType = CommandType.Text
.CommandText = sql
.Connection = cn
.Parameters.Clear()
.Parameters.Add("@Pet_ID", SqlDbType.NVarChar, 5).Value = TextBox1.Text
.Parameters.Add("@Name_PET", SqlDbType.NVarChar, 50).Value = TextBox2.Text
'.Parameters.Add("@Type_Name", SqlDbType.NVarChar, 50).Value = ComboBox1.SelectedValue
.Parameters.Add("@Bind", SqlDbType.NVarChar, 50).Value = TextBox4.Text
.Parameters.Add("@Sex", SqlDbType.NVarChar, 2).Value = TextBox5.Text
.ExecuteNonQuery()
End With
TextBox1.Clear()
TextBox2.Clear()
TextBox4.Clear()
TextBox5.Clear()
MessageBox.Show("บันทึกข้อมูลแล้ว")
setlock(True, False)
Tag : .NET, Ms SQL Server 2005, VB.NET
|
|
 |
 |
 |
 |
Date :
2011-02-10 17:56:02 |
By :
nokko |
View :
1064 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
insert into PET,TYPE,(Pet_ID,Name_PET,Type_Name,Bind,Sex)
|
 |
 |
 |
 |
Date :
2011-02-10 17:59:47 |
By :
PlaKriM |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|