webservice-转换odbc访问连接到SQL Server(webservice- converting odbc access connections to sql server)
我正在尝试将我的软件从odbc连接更新到我的新sql server。 新的sql连接默认为旧数据库(参见下面的代码)。 我甚至试图保持sql的odbc连接并指向我的新数据库,但webservice返回一个布尔值,而不是soap。 sql server是为较新的webservice设置和工作的。 我错过了什么?
这是旧代码:
<WebMethod()> Public Function LookupItem(ByVal strUPC As String) As DataSet Try Dim connUPC As New Odbc.OdbcConnection Dim ConnectionString As String Dim strSQL As String '//get upc info strSQL = "SELECT Inv_Qty.*,PLU.*,PLU.PLU_NUM, PLU.DEPT_NUM From PLU INNER JOIN Inv_Qty ON PLU.PLU_NUM=Inv_Qty.PLU_NUM WHERE ((PLU.PLU_NUM) = '" & strUPC & "');" ConnectionString = "DSN=mainODBC" connUPC.ConnectionString = ConnectionString Dim cmdUPC As New Odbc.OdbcCommand(strSQL, connUPC) Dim dsUPC As DataSet = New DataSet Dim daUPC As Odbc.OdbcDataAdapter = New Odbc.OdbcDataAdapter(cmdUPC) connUPC.Open() daUPC.Fill(dsUPC, "TC") connUPC.Close() connUPC = Nothing Return dsUPC Catch ex As Exception End Try End Function
我试图改变连接:
<WebMethod()> Public Function LookupItem(ByVal strUPC As String) As DataSet Try Dim connUPC As New Data.SqlClient.SqlConnection Dim ConnectionString As String Dim strSQL As String '//get upc info strSQL = "SELECT Inv_Qty.*,PLU.*,PLU.PLU_NUM, PLU.DEPT_NUM From PLU INNER JOIN Inv_Qty ON PLU.PLU_NUM=Inv_Qty.PLU_NUM WHERE ((PLU.PLU_NUM) = '" & strUPC & "');" ConnectionString = "Data Source=localhost\db;Initial Catalog=DB_SQL;Persist Security Info=True;User ID=myID;Password=myPass" connUPC.ConnectionString = ConnectionString Dim cmdUPC As New Data.SqlClient.SqlCommand(strSQL, connUPC) Dim dsUPC As DataSet = New DataSet Dim daUPC As Data.SqlClient.SqlDataAdapter = New Data.SqlClient.SqlDataAdapter(cmdUPC) connUPC.Open() daUPC.Fill(dsUPC, "TC") connUPC.Close() connUPC = Nothing Return dsUPC Catch ex As Exception End Try End Function
I'm trying to update my software from odbc connections to my new sql server. The new sql connections are defaulting to the old database (see below code). I've even tried to keep the odbc connections for sql and point to my new db, but the webservice is returning a boolean, not the soap. The sql server is setup for and working on a newer webservice. What am I missing?
Here is the old code:
<WebMethod()> Public Function LookupItem(ByVal strUPC As String) As DataSet Try Dim connUPC As New Odbc.OdbcConnection Dim ConnectionString As String Dim strSQL As String '//get upc info strSQL = "SELECT Inv_Qty.*,PLU.*,PLU.PLU_NUM, PLU.DEPT_NUM From PLU INNER JOIN Inv_Qty ON PLU.PLU_NUM=Inv_Qty.PLU_NUM WHERE ((PLU.PLU_NUM) = '" & strUPC & "');" ConnectionString = "DSN=mainODBC" connUPC.ConnectionString = ConnectionString Dim cmdUPC As New Odbc.OdbcCommand(strSQL, connUPC) Dim dsUPC As DataSet = New DataSet Dim daUPC As Odbc.OdbcDataAdapter = New Odbc.OdbcDataAdapter(cmdUPC) connUPC.Open() daUPC.Fill(dsUPC, "TC") connUPC.Close() connUPC = Nothing Return dsUPC Catch ex As Exception End Try End Function
I've tried to just change the connections:
<WebMethod()> Public Function LookupItem(ByVal strUPC As String) As DataSet Try Dim connUPC As New Data.SqlClient.SqlConnection Dim ConnectionString As String Dim strSQL As String '//get upc info strSQL = "SELECT Inv_Qty.*,PLU.*,PLU.PLU_NUM, PLU.DEPT_NUM From PLU INNER JOIN Inv_Qty ON PLU.PLU_NUM=Inv_Qty.PLU_NUM WHERE ((PLU.PLU_NUM) = '" & strUPC & "');" ConnectionString = "Data Source=localhost\db;Initial Catalog=DB_SQL;Persist Security Info=True;User ID=myID;Password=myPass" connUPC.ConnectionString = ConnectionString Dim cmdUPC As New Data.SqlClient.SqlCommand(strSQL, connUPC) Dim dsUPC As DataSet = New DataSet Dim daUPC As Data.SqlClient.SqlDataAdapter = New Data.SqlClient.SqlDataAdapter(cmdUPC) connUPC.Open() daUPC.Fill(dsUPC, "TC") connUPC.Close() connUPC = Nothing Return dsUPC Catch ex As Exception End Try End Function
原文:https://stackoverflow.com/questions/15765044
最满意答案
是的你应该添加。 如果你认为你将有很多查询得到这些领域的条件。 在你的情况下,我认为你可能有很多查询,比如生活在一个区域的人,所以我会在用户表上为(id(user_id)和region_id字段在一个单独的索引中创建一个索引)
add_index :users, [:id, :user_id]
Yes you should add. If you think to you are going to have lot of query that got condition for those fields. In your case I think you might have lot queries like people living in one region, so I would create a index on users table for (id(user_id) and region_id fields together in one single index)
add_index :users, [:id, :user_id]
相关问答
更多-
您需要删除外键约束。 您还可以保留外键约束并使用“软删除”,一旦用户设置为已删除,就可以将布尔字段设置为true。 事实仍然是:如果您使用外键约束,那么您将需要进行级联删除。 You need to remove the foreign key constraint. You could also keep the foreign key constraints and use "soft deletes" which could set a Boolean field to true once a use ...
-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
你的sintax似乎是正确的。 不,没有自动插入所需值的方法。 您只能在添加约束之前手动执行此操作。 在你的情况下必须是这样的 INSERT INTO frontend_pct (code) SELECT code FROM ( SELECT DISTINCT pct_code AS code FROM frontend_item WHERE pct_code NOT IN (SELECT code FROM frontend_pct) ) AS a; 如果您有大量数据,查询可以是 ...
-
从精细手册 : 5.3.5。 外键 [...] 由于引用表中的行的DELETE或引用列的UPDATE将需要扫描引用表以查找与旧值匹配的行,因此通常最好对引用列建立索引。 因为并不总是需要这个,并且有很多关于如何索引的选择,所以外键约束的声明不会自动在引用列上创建索引。 你是FK引用PK所以你可能不必担心UPDATE。 如果您的引用表(具有club_id表)将会很大并且您希望经常删除club行,那么club_id上的某种索引应该会更快地删除club行。 如果你在club_id上没有索引, club_id尝试删 ...
-
在Rails迁移中为表添加索引的正确方法是什么?(What's the proper way to add an index to a table in a Rails migration?)[2023-08-20]
add_index 'crypto_index_currencies', ['crypto_currency'], name: "index_crypto_index_currencies_on_crypto_currency", unique: true, using: :btree 使用::btree其可选。 add_index 'crypto_index_currencies', ['crypto_currency'], name: "index_crypto_index_currencies_o ... -
rails无法索引外键(rails unable to index a foreign key)[2022-07-08]
尝试: class CreateClientProfiles < ActiveRecord::Migration def change create_table :client_profiles do |t| t.belongs_to :contact t.belongs_to :lead_profile t.timestamps end add_index :client_profiles, :contact_id add_inde ... -
是的你应该添加。 如果你认为你将有很多查询得到这些领域的条件。 在你的情况下,我认为你可能有很多查询,比如生活在一个区域的人,所以我会在用户表上为(id(user_id)和region_id字段在一个单独的索引中创建一个索引) add_index :users, [:id, :user_id] Yes you should add. If you think to you are going to have lot of query that got condition for those fields. ...
-
这是由于PostgreSql不了解如何使自定义关联外键。 尝试将迁移文件更改为, class CreateTransactions < ActiveRecord::Migration def change create_table :transactions do |t| t.integer :buyer_id t.integer :seller_id t.integer :product_id t.timestamps null: false ...
-
我认为你有大部分正确的部分,但需要重新组合它们,例如这应该有效: class Friend < ApplicationRecord belongs_to :friend1, :foreign_key => :friend1_id, :class_name => 'User' belongs_to :friend2, :foreign_key => :friend2_id, :class_name => 'User' end 如果您的列是friend_1 / friend_2 create_tabl ...
-
如果它不是第一个索引,则必须添加额外的索引。 所以,如果你有这个: add_index :templates, [:name, :account_id], unique: true 那么你不应该删除原来的:account_id外键索引,因为它是第二个索引。 我建议你阅读有关索引实现。 这很有趣,你可以从中学到很多东西。 You have to add extra index if it's not the first index. So if you have this: add_index :templa ...