|
大家好- Private Sub CommandButton1_Click()
- Dim conn As New ADODB.Connection
- Dim rs2 As Object
- Dim server_name As String
- Dim database_name As String
- Dim user_id As String
- Dim password As String
- Dim strsqlstatus As String
- Set conn = New ADODB.Connection
- Set rs2 = New ADODB.Recordset
- server_name = "127.0.0.1"
- database_name = "jira"
- user_id = "123"
- password = "123"
- conn.Open "DRIVER={MySQL ODBC 5.1 Driver}" _
- & ";SERVER=" & server_name _
- & ";port=" & 3307 _
- & ";DATABASE=" & database_name _
- & ";UID=" & user_id _
- & ";PWD=" & password _
- & ";Stmt=set names GBK" _
- & ";OPTION=16427"
- strsqlstatus = "select * from changeitem where field='status'"
- With rs2
- .Open strsqlstatus, conn
- Worksheets("sheet1").Range("a1").Offset(1, 0).CopyFromRecordset rs2
- End With
- Set rs2 = Nothing
- conn.Close
- Set conn = Nothing
- End Sub
复制代码 如上代码中,最后一个需要查询的数据,始终无法导入.
查看数据库发现,该数据类型为:longtext.
查看microsoft资料,看到如下一句话:
若要将大于 255 个字符的字符串成功地保存到 Excel 列中,驱动程序必须将该目标列的数据类型识别为 memo,而不是 string
不知该如何处理,请教大家.
[ 本帖最后由 ftoilove 于 2011-1-30 17:25 编辑 ] |
|