嗨,我創建了一個私人子代,其中的代碼必須插入一個MySQL命令....它的確如此,但最有趣的部分是,該記錄從數據庫中消失 它在那裏,但是我停止了debbug,重新開始它不在那裏,即使在數據庫 爲什麼?空白mysql插入到數據庫
Private Sub gravarAtleta()
Dim sqlStatement = "insert into atl([nome],[morada],[sexo],[datan],[telf],[desporto]) "
sqlStatement &= "VALUES (@nome, @morada, @sexo, @datan, @telf, @desporto)"
Using xConn As New SqlConnection(myConnectionString)
Try
Dim xComm As New SqlCommand(sqlStatement, xConn)
With xComm
.CommandType = CommandType.Text
.Parameters.AddWithValue("@nome", txtNome.Text)
.Parameters.AddWithValue("@morada", txtMorada.Text)
.Parameters.AddWithValue("@sexo", ComboSexo.Text)
.Parameters.AddWithValue("@datan", CType(txtDataN.Text, DateTime).ToString("yyyy-MM-dd"))
.Parameters.AddWithValue("@telf", txtTelemovel.Text)
.Parameters.AddWithValue("@desporto", ComboBox1.Text)
End With
xConn.Open()
xComm.ExecuteNonQuery()
xComm.Dispose()
Label1.Content = "O atleta " + txtNome.Text + " foi registado!!!"
Catch ex As SqlException
MsgBox(ex.Message)
Label1.Content = "Falhou a ligação a base de dados!!!"
End Try
End Using
End Sub
Leva如果你必須插入一個mysql命令爲什麼SQL Server連接? – 2012-07-30 09:17:36