Sathya Narayan

Sathya Narayan

  • NA
  • 155
  • 65k

Error in connection string

Jan 21 2014 6:03 AM
hi ,

i am getting this error that Keyword not supported: 'provider'.When i am going to connect with access database the its showing like this.

This is my connection string.
Public Const cnString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\sa.accdb"


This is my code
Private Sub savedata()
        'On Error Resume Next
        If TextBox1.Text = "" Then
            MsgBox("Enter The Section")
            TextBox1.Focus()

        Else
            Dim res = MessageBox.Show("Would You Like To Insert Section Details Record ?", "Save", MessageBoxButtons.YesNo)
            If res = Windows.Forms.DialogResult.Yes Then
                Dim Adapter As New SqlDataAdapter
                Dim cmd1 As New SqlCommand
                Dim Sql1 As String
                conn = New SqlConnection(cnString)

                Sql1 = "insert into SecMaster(Subject) values('" & TextBox1.Text.Replace("'", "''") & "')"
        
                conn.Open()
                Adapter.InsertCommand = New SqlCommand(Sql1, conn)
                Adapter.InsertCommand.ExecuteNonQuery()
                conn.Close()
                Button5.Enabled = False
                Button6.Enabled = False
                Button2.Enabled = False
                TextBox1.Enabled = False
                GroupBox1.Enabled = False
                clear()
            End If
            conn.Close()
        End If
    End Sub 

Can any one help????



Answers (2)