AndreVSerafim Posted October 22, 2015 at 07:04 PM Report Share #589083 Posted October 22, 2015 at 07:04 PM Boas malta, Alguém pode me ajudar o porque de estar a dar o erro MySqlException was unhandled? MySql.Data.MySqlClient.MySqlException was unhandledAn unhandled exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll Additional information: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''22-10-2015)' at line 1 O SQL está tão simples como o código ser a chave primaria e configurado como varchar (100) assim como o campo nome e dia. Imports MySql.Data.MySqlClient Public Class conn Public VarConec As String Public Sub New() Dim servidor As String Dim usuario As String Dim password As String Dim basedados As String servidor = "localhost" usuario = "root" password = "" basedados = "teste" VarConec = "server=" & servidor & "; user id=" & usuario & "; password=" & password & "; database=" & basedados & ";" End Sub Public Function Conectar() As Boolean Dim Conexao As New MySqlConnection(VarConec) Try Conexao.Open() Catch ex As Exception MsgBox(ex.Message) End Try 'retorna variavel State Open 1, Close 0 Return Conexao.State End Function End Class Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim obj As New conn If obj.Conectar() Then MsgBox("Conectou!") Else MsgBox("Erro conexão!") End If Dim Var1 As String Var1 = TextBox1.Text Dim Var2 As String Var2 = TextBox2.Text Dim Var3 As Date Var3 = Date.Today Dim Var4 = Var3.ToString("dd-MM-yyyy") MsgBox("O conteudo da caixa 1 é " & Var1 & " e conteudo da caixa 2 é " & Var2 & " dia " & Var4) Dim Conexao As New conn Dim objConexao As New MySqlConnection(Conexao.VarConec) Dim Varsql As String Varsql = "INSERT INTO nomecodigos (codigo, nome, dia) VALUES ('" & Var1 & "','" & Var2 & "','" & Var4 & ")" Dim objMysqlCommand As New MySqlCommand(Varsql, objConexao) objConexao.Open() objMysqlCommand.ExecuteNonQuery() objConexao.Close() End Sub End Class Link to comment Share on other sites More sharing options...
felipe_live Posted June 3, 2016 at 12:10 PM Report Share #596854 Posted June 3, 2016 at 12:10 PM Alguém poderia me ajudar? Sou um novato na área de programação. Eu tenho duas ComboBox com informações puxada de uma tabela do SQLServer Quando o usuário selecionar as informações desejadas da ComboBox e clicar no botão Salvar, essas informações tem que ir para uma outra tabela do SQLServer. Cada ComboBox corresponde a uma coluna da tabela. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now