关键词:"提供商QUOT;不支持? [英] Keyword:"provider" not supported?

查看:129
本文介绍了关键词:"提供商QUOT;不支持?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!我正在使用vb.net开发一个排队系统,我将数据库从ms访问更改为sql server 2014,在我更改连接字符串并调试我的程序后出现一个错误框,表示不支持关键字:提供程序。 。我不知道如何以及如何使我的程序将数据保存到我的sql数据库。这个程序的正确代码语法是什么?谢谢!



我尝试过:



Hi! I'm developing a queuing system using vb.net and I changed my database from ms access to sql server 2014, after I change the connection string and debugged my program an error box appeared that said "Keyword:"Provider" is not supported.". I don't know how and what I should do to make my program save data to my sql database. What is the correct code syntax for this program? Thanks!

What I have tried:

Imports System.Data.SqlClient










Dim sqlconn As New SqlConnection
       Dim sqlquery As New SqlCommand
       Dim connString As String
       Try
           connString = "Provider=SQLNCLI11;Data Source=MISKRISTIAN-PC\HMO_OPD;Integrated Security=SSPI;Initial Catalog=HMO_OPD_QUEUE"
           sqlconn.ConnectionString = connString
           sqlquery.Connection = sqlconn
           sqlconn.Open()
           sqlquery.CommandText = "INSERT INTO Query1([Number])VALUES(@Number)"
           sqlquery.Parameters.AddWithValue("@Number", NumApp.Text)
           sqlquery.ExecuteNonQuery()
           sqlconn.Close()
       Catch ex As Exception
           MessageBox.Show(ex.Message)
       End Try

推荐答案

SQL不支持供应商关键字 - 将其删除并包括第一个分号,它应该可以工作。



但是请帮自己一个忙,不要硬编码连接字符串。当您发布到生产环境时,您必须更改它的位置是荒谬的,通常意味着您的代码在发布时未经过适当的测试。使用配置文件,或者看到:实例存储 - 一个简单的在应用程序之间共享配置数据的方法 [ ^ ]
SQL does not support the "Provider" keyword - remove it up to and including the first semicolon and it should work.

But do yourself a favour and never hard-code connection strings. The number of place you have to change it when you release to production is ridiculous and generally means your code is not properly tested when you publish it. Use a configuration file, or see this: Instance Storage - A Simple Way to Share Configuration Data among Applications[^]


为什么使用SQL Server Native Client 11.0 OLE DB提供程序?请注意, OLE DB和ODBC不支持SQL Server 2005及更高版本中的某些新功能。托管的.Net提供程序支持.SQL Native Client可以看作是可以从本机(非.Net)代码访问新SQL Server功能的解决方案。使用它没有其他好处。 请参阅:何时使用SQL Native Client [ ^ ]



我强烈建议使用.NET SQL Server的框架数据提供程序。请参阅: SQL Server连接字符串 - ConnectionStrings.com [ ^ ]
Why are you using SQL Server Native Client 11.0 OLE DB Provider? Note, that "OLE DB and ODBC does not support some of the new features in SQL Server 2005 and later. The managed .Net providers does. The SQL Native Client can be seen as a solution to have access to the new SQL Server features from native (non .Net) code. There are no other benefits from using it." See: When to use the SQL Native Client[^]

I'd strongly recommend to use .NET Framework Data Provider for SQL Server. See: SQL Server connection strings - ConnectionStrings.com[^]


这篇关于关键词:"提供商QUOT;不支持?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆