당신의 SQL이 실패하는 이유는 "추가하기"예약어이다 . 즉, 대괄호 ([]) 안에 넣지 않고서는 사용할 수 없습니다. 데이터 유형을 삽입하려고 일치하지 않는 경우 텍스트를 삽입하려고, 그래서 만약 당신이 ...
Using oleCmd As New OleDbCommand("Insert Into users1 (num,name1,pass,[add],phone) values (@num,@name1,@pass,@add,@phone)", con)
oleCmd.Parameters.Add("@num", OleDbType.Integer).Value = Textbox1.Text
oleCmd.Parameters.Add("@name1", OleDbType.VarChar).Value = Textbox2.Text
oleCmd.Parameters.Add("@pass", OleDbType.VarChar).Value = Textbox3.Text
oleCmd.Parameters.Add("@address", OleDbType.VarChar).Value = Textbox4.Text
oleCmd.Parameters.Add("@phone", OleDbType.Integer).Value = Textbox5.Text
oleCmd.ExecuteNonQuery()
End Using
Using oleCmd As New OleDbCommand("Insert Into users1 (num,name1,pass,[add],phone) Values (?,?,?,?,?)", con)
oleCmd.Parameters.AddWithValue("?", Textbox1.Text)
oleCmd.Parameters.AddWithValue("?", Textbox2.Text)
oleCmd.Parameters.AddWithValue("?", Textbox3.Text)
oleCmd.Parameters.AddWithValue("?", Textbox4.Text)
oleCmd.Parameters.AddWithValue("?", Textbox5.Text)
oleCmd.ExecuteNonQuery()
End Using
주 쿼리의 파라미터를, 그래서 작동이 중 하나를해야 이상, 그것은 실패합니다 전화 번호 또는 전화 번호는 실패합니다. 입력 내용의 유효성을 검사하고 텍스트 상자 텍스트를 사용하는 대신 변환하는 것이 바람직합니다.