unsupported keyword 'provider'

0

Hello good day I am developing an ABC system everything I do with SQl Connection and it worked perfect but I found a code to validate if there was a record in the database with the same name this example used an OleDb (it works) but at the time of wanting to modify a record I get the error of the title of the publication.

I leave the code I use:

This is for the update

Dim cnn As New SqlConnection 
Dim conexion As String = "Provider=SQLOLEDB;Data Source=servidor;Initial Catalog=BD;user id = user; password = pass"
cnn = New SqlConnection(conexion)
            cnn.Open()
            cmd = New SqlCommand("modlin", cnn)
            cmd.CommandType = CommandType.StoredProcedure
            cmd.Parameters.Add("@idline", SqlDbType.VarChar).Value = ComboBox2.Text
            cmd.Parameters.Add("@lin", SqlDbType.NVarChar).Value = ComboBox1.Text
            cmd.Parameters.Add("@prens", SqlDbType.VarChar).Value = TextBoxPrensa.Text
            cmd.Parameters.Add("@diin", SqlDbType.VarChar).Value = tb_diamin.Text
            cmd.Parameters.Add("@diex", SqlDbType.VarChar).Value = tbdiamex.Text
            cmd.Parameters.Add("@pes_roll", SqlDbType.VarChar).Value = tb_pesroll.Text
            cmd.Parameters.Add("@fech", SqlDbType.DateTime).Value = DateTimePicker1.Text
            cmd.ExecuteNonQuery()
            MessageBox.Show("Registro Modificado")
            ComboBox1.Text = ""
            TextBoxPrensa.Text = ""
            DateTimePicker1.Text = ""
            ComboBox2.Text = ""
            tb_diamin.Text = ""
            tbdiamex.Text = ""
            tb_pesroll.Text = ""
            ErrorProvider1.Clear()
            ComboBox1.Text = ""
            TextBoxPrensa.Text = ""
            DateTimePicker1.Text = ""
            ComboBox2.Text = ""
            tb_diamin.Text = ""
            tbdiamex.Text = ""
            tb_pesroll.Text = ""
            ErrorProvider1.Clear()

this is what I use for validation:

Dim consultaSQL As String = "SELECT linea from linea where linea ='" & Me.ComboBox1.SelectedValue.ToString & "'"

    Dim Da As New OleDbDataAdapter(consultaSQL, conexion)
    Dim Dt As New DataTable
    Da.Fill(Dt)
    If Dt.Rows.Count > 0 Then

        MessageBox.Show("Linea Duplicada Intente Con Otra... (Ignore Este Mensaje Si Va A Modificar El Registro)")
        BtnRegis.Enabled = False
    Else
        BtnRegis.Enabled = True
    End If

I hope you can help me, thanks ...

    
asked by Cristian 26.03.2018 в 20:30
source

1 answer

0

The Conection string has to be:

Dim connectionString AS String = "Server=my_server;Database=name_of_db;User Id=user_name;Password=my_password"

the conection string you use is for OleDb

    
answered by 26.03.2018 в 20:36