简体   繁体   English

未在ConnectionString中指定OLE DB提供程序。 'Provider = SQLOLEDB;

[英]An OLE DB Provider was not specified in the ConnectionString. 'Provider=SQLOLEDB;

i trying to run query using C#, i am getting the following problem 我试图使用C#运行查询,但出现以下问题

An OLE DB Provider was not specified in the ConnectionString. 未在ConnectionString中指定OLE DB提供程序。 An example would be, 'Provider=SQLOLEDB; 例如,“ Provider = SQLOLEDB;

my code 我的代码

string strConString = System.Configuration.ConfigurationManager.ConnectionStrings["WorkflowConnStr"].ConnectionString.ToString(); 
string sqlstr = "select * from table"        
OleDbConnection myConnection = new OleDbConnection(strConString);
try
     {myConnection.Open();}
catch (Exception err) 
     { System.Diagnostics.Debug.WriteLine(err.Message); }

OleDbCommand myCommand = new OleDbCommand(sqlstr, myConnection);
OleDbDataReader reader = myCommand.ExecuteReader();

web.config web.config

<add name="WorkflowConnStr" connectionString="Data Source=Server;Initial Catalog=DBName;user id=usr;password=password" providerName="System.Data.OleDb.OleDbConnection"/>

any suggestion ? 有什么建议吗?

Try adding this to your connection string, 尝试将其添加到您的连接字符串中,

Provider=SQLNCLI10.1

So it would be; 那就这样;

<add name="WorkflowConnStr" connectionString="Data Source=Server;Initial Catalog=DBName;user id=usr;password=password;Provider=SQLNCLI10.1" providerName="System.Data.OleDb.OleDbConnection"/>

使用SqlConnection代替OleDbConnection

same error here, please help! 同样的错误在这里,请帮忙!

An OLE DB Provider was not specified in the ConnectionString . 未在ConnectionString指定OLE DB提供程序。 An example would be, Provider=SQLOLEDB ; 一个示例是Provider=SQLOLEDB

heres my code! 这是我的代码! thank you! 谢谢!

Imports System.Data.OleDb

Public Class Form1

Dim provider As String
Dim datafile As String
Dim connstring As String
Dim myConnection As OleDbConnection = New OleDbConnection

Private Sub PDSBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Me.Validate()
    Me.PDSBindingSource.EndEdit()
    Me.TableAdapterManager.UpdateAll(Me.PDSDatabase1DataSet)

End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'TODO: This line of code loads data into the 'PDSDatabase1DataSet.PDS' table. You can move, or remove it, as needed.
    Me.PDSTableAdapter.Fill(Me.PDSDatabase1DataSet.PDS)

End Sub


Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
    Me.Close()

End Sub

Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
    Badge_NumberTextBox.Clear()
    RankTextBox.Clear()
    SurnameTextBox.Clear()
    First_NameTextBox.Clear()
    Middle_NameTextBox.Clear()
    Name_ExtensionTextBox.Clear()
    Date_of_BirthTextBox.Clear()
    Place_of_BirthTextBox.Clear()
    GenderTextBox.Clear()
    Civil_StatusTextBox.Clear()
    WeightTextBox.Clear()
    HeightTextBox.Clear()
    Blood_TypeTextBox.Clear()
    CitizenshipTextBox.Clear()
    Telephone_NoTextBox.Clear()
    Mobile_NoTextBox.Clear()
    Email_AddressTextBox.Clear()
    Residential_AddressTextBox.Clear()
    Permanent_AddressTextBox.Clear()
    GSIS_ID_NoTextBox.Clear()
    PAG_IBIG_ID_NoTextBox.Clear()
    PHILHEALTH_NoTextBox.Clear()
    SSS_NoTextBox.Clear()
    TIN_NoTextBox.Clear()
    Agency_Employee_NoTextBox.Clear()

End Sub

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click


    provider = "Provider-Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\BJMP\Desktop\Sample\PDSDatabase1.accdb"
    connstring = provider
    myConnection.ConnectionString = connstring
    myConnection.Open()


    Dim str As String
    str = "Insert into([Badge Number:],[Rank:],[Surname:],[First Name:],[Middle Name:],[Name Ext.],[Date of Birth: (January 01, 2000)],[Place of Birth:],[Gender:],[Civil Status:],[Weight(kg):],[Height(cm):],[Blood Type:],[Citizenship:],[Telephone No:],[Mobile No:],[Email Address: (if any)],[Residential Address: (House No., Street/Barangay, Municipality, Province, Zip Code)],[Permanent Address: (House No., Street/Barangay, Municipality, Province, Zip Code)],[GSIS ID No:],[PAG-IBIG ID No:],[PHILHEALTH No:],[SSS No:],[TIN No:],[Agency Employee No:]) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
    Dim cmd As OleDbCommand = New OleDbCommand(str, myConnection)
    cmd.Parameters.Add(New OleDbParameter("Badge Number:", CType(Badge_NumberTextBox.Text, String)))
    cmd.Parameters.Add(New OleDbParameter("Rank:", CType(RankTextBox.Text, String)))
    cmd.Parameters.Add(New OleDbParameter("Surname:", CType(SurnameTextBox.Text, String)))
    cmd.Parameters.Add(New OleDbParameter("First Name:", CType(First_NameTextBox.Text, String)))
    cmd.Parameters.Add(New OleDbParameter("Middle Name:", CType(Middle_NameTextBox.Text, String)))
    cmd.Parameters.Add(New OleDbParameter("Name Ext.:", CType(Name_ExtensionTextBox.Text, String)))
    cmd.Parameters.Add(New OleDbParameter("Date of Birth: (January 01, 2000)", CType(Date_of_BirthTextBox.Text, String)))
    cmd.Parameters.Add(New OleDbParameter("Place of Birth:", CType(Place_of_BirthTextBox.Text, String)))
    cmd.Parameters.Add(New OleDbParameter("Gender:", CType(GenderTextBox.Text, String)))
    cmd.Parameters.Add(New OleDbParameter("Civil Status:", CType(Civil_StatusTextBox.Text, String)))
    cmd.Parameters.Add(New OleDbParameter("Weight(kg):", CType(WeightTextBox.Text, String)))
    cmd.Parameters.Add(New OleDbParameter("Height(cm):", CType(HeightTextBox.Text, String)))
    cmd.Parameters.Add(New OleDbParameter("Blood Type:", CType(Blood_TypeTextBox.Text, String)))
    cmd.Parameters.Add(New OleDbParameter("Citizenship:", CType(CitizenshipTextBox.Text, String)))
    cmd.Parameters.Add(New OleDbParameter("Telephone No:", CType(Telephone_NoTextBox.Text, String)))
    cmd.Parameters.Add(New OleDbParameter("Mobile No:", CType(Mobile_NoTextBox.Text, String)))
    cmd.Parameters.Add(New OleDbParameter("Email Address: (if any)", CType(Email_AddressTextBox.Text, String)))
    cmd.Parameters.Add(New OleDbParameter("Residential Address: (House No., Street/Barangay, Municipality, Province, Zip Code)", CType(Residential_AddressTextBox.Text, String)))
    cmd.Parameters.Add(New OleDbParameter("Permanent Address: (House No., Street/Barangay, Municipality, Province, Zip Code)", CType(Permanent_AddressTextBox.Text, String)))
    cmd.Parameters.Add(New OleDbParameter("GSIS ID No::", CType(GSIS_ID_NoTextBox.Text, String)))
    cmd.Parameters.Add(New OleDbParameter("PAG-IBIG ID No::", CType(PAG_IBIG_ID_NoTextBox.Text, String)))
    cmd.Parameters.Add(New OleDbParameter("PHILHEALTH No:", CType(PHILHEALTH_NoTextBox.Text, String)))
    cmd.Parameters.Add(New OleDbParameter("SSS No:", CType(SSS_NoTextBox.Text, String)))
    cmd.Parameters.Add(New OleDbParameter("TIN No:", CType(TIN_NoTextBox.Text, String)))
    cmd.Parameters.Add(New OleDbParameter("Agency Employee No:", CType(Agency_Employee_NoTextBox.Text, String)))

    Try
        cmd.ExecuteNonQuery()
        cmd.Dispose()
        myConnection.Close()
        Badge_NumberTextBox.Clear()
        RankTextBox.Clear()
        SurnameTextBox.Clear()
        First_NameTextBox.Clear()
        Middle_NameTextBox.Clear()
        Name_ExtensionTextBox.Clear()
        Date_of_BirthTextBox.Clear()
        Place_of_BirthTextBox.Clear()
        GenderTextBox.Clear()
        Civil_StatusTextBox.Clear()
        WeightTextBox.Clear()
        HeightTextBox.Clear()
        Blood_TypeTextBox.Clear()
        CitizenshipTextBox.Clear()
        Telephone_NoTextBox.Clear()
        Mobile_NoTextBox.Clear()
        Email_AddressTextBox.Clear()
        Residential_AddressTextBox.Clear()
        Permanent_AddressTextBox.Clear()
        GSIS_ID_NoTextBox.Clear()
        PAG_IBIG_ID_NoTextBox.Clear()
        PHILHEALTH_NoTextBox.Clear()
        SSS_NoTextBox.Clear()
        TIN_NoTextBox.Clear()
        Agency_Employee_NoTextBox.Clear()
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try

End Sub

End Class 末级

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未在ConnectionString中指定OLE DB提供程序。 例如,“ Provider = SQLOLEDB;” - An OLE DB Provider was not specified in the ConnectionString. An example would be, 'Provider=SQLOLEDB;' 未在ConnectionString中指定OLE DB提供程序。 &#39;提供者= SQLOLEDB - An OLE DB Provider was not specified in the ConnectionString. 'Provider=SQLOLEDB 如何使用 VFP OLE DB 提供程序关闭表 - How to close a table with the VFP OLE DB Provider 基础提供程序在ConnectionString上失败 - The underlying provider failed on ConnectionString 在 EF 6 连接字符串中使用 provider=SQLOLEDB - Use of provider=SQLOLEDB in EF 6 connection string 基础提供程序连接字符串失败 - Underlying provider failed in connectionstring Microsoft Office 12.0 Access 数据库引擎 OLE DB 提供程序 - Microsoft Office 12.0 Access database engine OLE DB Provider 如何获得提供者名称以打开Ole DB连接? - How do I get provider name to open Ole DB connection? 使用OLE DB .NET Provider插入数据库表将不起作用 - Insert into database table with OLE DB .NET Provider won't work 以编程方式添加SSIS连接 - OLE DB的Oracle提供程序 - Adding SSIS Connections Programmatically - Oracle Provider for OLE DB
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM