我想要SQL语句,因为我是要在VB.net中实现的
10 个解决方案
#1
insert into [;database=d:\a.mdb].b1
select * from [;database=d:\b.mdb].b1
select * from [;database=d:\b.mdb].b1
#2
oledbconn -> Access数据库1
olecmd "insert into A select * from [;database=C:\数据库1.mdb].B"
olecmd "insert into A select * from [;database=C:\数据库1.mdb].B"
#3
这是我按照你说法的VB.Net 代码,但是运行不了,麻烦看一下:
Private Sub JoinMDB()
Dim m_SqlConnStr As String = "provider=microsoft.jet.oledb.4.0;data source=D:\Svn\Steven\JC020786\mscs\BKGMODE_Final\APAC-GCR CS QoS Result.mdb"
Dim myConn As New OleDbConnection(m_SqlConnStr)
Dim myCmd As OleDbCommand
Dim myDataReader As OleDbDataReader
myConn.Open()
myCmd = New OleDbCommand("insert into APGC_PreSales_Result select * from [;database=D:\Svn\Steven\JC020786\mscs\BKGMODE_Final\APAC-GCR CS QoS Result_b.mdb].APGC_PreSales_Result", myConn)
myDataReader = myCmd.ExecuteReader() ‘这里报错
MsgBox(myDataReader(0))
myDataReader.Close()
myConn.Close()
End Sub
#4
Private Sub JoinMDB()
Dim m_SqlConnStr As String = "provider=microsoft.jet.oledb.4.0;data source=D:\Svn\T_a.mdb"
Dim myConn As New OleDbConnection(m_SqlConnStr)
Dim myCmd As OleDbCommand
'Dim myDataReader As OleDbDataReader
myConn.Open()
myCmd = New OleDbCommand("insert into APGC_PreSales_Result select * from [;database=D:\Svn\T_B.mdb].APGC_PreSales_Result", myConn)
myCmd.ExecuteReader() 'throw exception
'myDataReader.Close()
myConn.Close()
End Sub
下面是报错信息:
The INSERT INTO statement contains the following unknown field name: 'ProductFamily'. Make sure you have typed the name correctly, and try the operation again.
#5
我想是因为第二个数据的表多了一个列了,我再试试看~
#6
insert into APGC_PreSales_Result select * from [;database=D:\Svn\T_B.mdb].APGC_PreSales_Result
先直接打开你的D:\Svn\T_a.mdb, 在查询设计器中执行这个SQL语句
先直接打开你的D:\Svn\T_a.mdb, 在查询设计器中执行这个SQL语句
#7
我是要实现在VB.Net中执行阿~
#8
做这个测试以确保你的SQL语句首先没有问题。一般来说排错的一种方法。先确保SQL没有问题,然后再查程序中有没有问题。
#9
下面代码已在VS2005测试OK。
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.OleDb;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
OleDbConnection cn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\temp\db1.mdb;User Id=admin;Password=;");
cn.Open();
OleDbCommand cmd = new OleDbCommand(@"insert into t3 select * from [;database=C:\temp\access\db2.mdb].t1", cn);
cmd.ExecuteNonQuery();
cn.Close();
}
}
}
#10
Private Sub JoinMDB()
Dim mdb102_Path As String
Dim mdb103_Path As String
mdb102_Path = "D:\Svn\T_a.mdb"
mdb103_Path = "D:\Svn\T_b.mdb"
Dim SqlConnStr As String = "provider=microsoft.jet.oledb.4.0;data source= " & mdb102_Path
Dim myConn As New OleDbConnection(SqlConnStr)
Dim myCmd As OleDbCommand
Dim sqlstr As String
'join APAC_PostSales_Result from task ID 102 to APAC_Frontline_Result to task ID 103
sqlstr = "insert into APAC_Frontline_Result select * from [;database=" & mdb103_Path & "].APAC_PostSales_Result"
myConn.Open()
myCmd = New OleDbCommand(sqlstr, myConn)
myCmd.ExecuteNonQuery()
myCmd = Nothing
myConn.Close()
'join APGC_PreSales_Result from task ID 102 to APGC_QoS_Result to task ID 103
sqlstr = "insert into APGC_QoS_Result select * from [;database=" & mdb103_Path & "].APGC_PreSales_Result"
myConn.Open()
myCmd = New OleDbCommand(sqlstr, myConn)
myCmd.ExecuteNonQuery()
myCmd = Nothing
myConn.Close()
End Sub
贴上我的代码供后人参考~
#1
insert into [;database=d:\a.mdb].b1
select * from [;database=d:\b.mdb].b1
select * from [;database=d:\b.mdb].b1
#2
oledbconn -> Access数据库1
olecmd "insert into A select * from [;database=C:\数据库1.mdb].B"
olecmd "insert into A select * from [;database=C:\数据库1.mdb].B"
#3
这是我按照你说法的VB.Net 代码,但是运行不了,麻烦看一下:
Private Sub JoinMDB()
Dim m_SqlConnStr As String = "provider=microsoft.jet.oledb.4.0;data source=D:\Svn\Steven\JC020786\mscs\BKGMODE_Final\APAC-GCR CS QoS Result.mdb"
Dim myConn As New OleDbConnection(m_SqlConnStr)
Dim myCmd As OleDbCommand
Dim myDataReader As OleDbDataReader
myConn.Open()
myCmd = New OleDbCommand("insert into APGC_PreSales_Result select * from [;database=D:\Svn\Steven\JC020786\mscs\BKGMODE_Final\APAC-GCR CS QoS Result_b.mdb].APGC_PreSales_Result", myConn)
myDataReader = myCmd.ExecuteReader() ‘这里报错
MsgBox(myDataReader(0))
myDataReader.Close()
myConn.Close()
End Sub
#4
Private Sub JoinMDB()
Dim m_SqlConnStr As String = "provider=microsoft.jet.oledb.4.0;data source=D:\Svn\T_a.mdb"
Dim myConn As New OleDbConnection(m_SqlConnStr)
Dim myCmd As OleDbCommand
'Dim myDataReader As OleDbDataReader
myConn.Open()
myCmd = New OleDbCommand("insert into APGC_PreSales_Result select * from [;database=D:\Svn\T_B.mdb].APGC_PreSales_Result", myConn)
myCmd.ExecuteReader() 'throw exception
'myDataReader.Close()
myConn.Close()
End Sub
下面是报错信息:
The INSERT INTO statement contains the following unknown field name: 'ProductFamily'. Make sure you have typed the name correctly, and try the operation again.
#5
我想是因为第二个数据的表多了一个列了,我再试试看~
#6
insert into APGC_PreSales_Result select * from [;database=D:\Svn\T_B.mdb].APGC_PreSales_Result
先直接打开你的D:\Svn\T_a.mdb, 在查询设计器中执行这个SQL语句
先直接打开你的D:\Svn\T_a.mdb, 在查询设计器中执行这个SQL语句
#7
我是要实现在VB.Net中执行阿~
#8
做这个测试以确保你的SQL语句首先没有问题。一般来说排错的一种方法。先确保SQL没有问题,然后再查程序中有没有问题。
#9
下面代码已在VS2005测试OK。
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.OleDb;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
OleDbConnection cn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\temp\db1.mdb;User Id=admin;Password=;");
cn.Open();
OleDbCommand cmd = new OleDbCommand(@"insert into t3 select * from [;database=C:\temp\access\db2.mdb].t1", cn);
cmd.ExecuteNonQuery();
cn.Close();
}
}
}
#10
Private Sub JoinMDB()
Dim mdb102_Path As String
Dim mdb103_Path As String
mdb102_Path = "D:\Svn\T_a.mdb"
mdb103_Path = "D:\Svn\T_b.mdb"
Dim SqlConnStr As String = "provider=microsoft.jet.oledb.4.0;data source= " & mdb102_Path
Dim myConn As New OleDbConnection(SqlConnStr)
Dim myCmd As OleDbCommand
Dim sqlstr As String
'join APAC_PostSales_Result from task ID 102 to APAC_Frontline_Result to task ID 103
sqlstr = "insert into APAC_Frontline_Result select * from [;database=" & mdb103_Path & "].APAC_PostSales_Result"
myConn.Open()
myCmd = New OleDbCommand(sqlstr, myConn)
myCmd.ExecuteNonQuery()
myCmd = Nothing
myConn.Close()
'join APGC_PreSales_Result from task ID 102 to APGC_QoS_Result to task ID 103
sqlstr = "insert into APGC_QoS_Result select * from [;database=" & mdb103_Path & "].APGC_PreSales_Result"
myConn.Open()
myCmd = New OleDbCommand(sqlstr, myConn)
myCmd.ExecuteNonQuery()
myCmd = Nothing
myConn.Close()
End Sub
贴上我的代码供后人参考~