摘要:
1,以Excel为数据源建立连接导入。关键点在于Excel的数据要有表头,表头要和数据库表的列名一样。连接字符串中HDR=YES不能省略,也就是第一行是表头的意思。IMEX=1;是把数据都当作字符串读取。Sub test() Dim cn As ADODB.Connection Dim strSQL As String Dim lngRecsAff As Long Dim Headers As Boolean Dim strConn As String Dim path As String On Error GoTo test_Err... 阅读全文
随笔档案-2013年12月
VBA中数据库导出数据到Excel注意事项
2013-12-03 18:35 by xiashengwang, 2751 阅读, 收藏, 编辑
摘要:
Sub ReadDBData() On Error GoTo ErrorHand Dim dbHelper As New dbHelper Dim sqlSQL As String Dim rs As ADODB.Recordset Dim row As Integer If dbHelper.OpenConnection(GetConnString()) Then sqlSQL = "select top(500) * from View_Column" Set rs = dbHelper.ExecuteReco... 阅读全文