这个问题我没有一点办法:无效的SQL语句。期待: "delete,insert,update,select,produce."

sharplee82 2003-11-05 10:03:07
conn = New oleDbConnection"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\DanJuDB.mdb")
conn.open()
Dim selectstring As String = "select * from 员工表"
Dim commstring As String = "bcp '" + selectstring + "' queryout " & filename & ".txt"
Dim sendtofilecomm As New OleDbCommand(commstring, conn)
sendtofilecomm.ExecuteNonQuery()'错误:
无效的SQL语句。期待: "delete,insert,update,select,produce."
...全文
664 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
fairleng 2003-11-06
  • 打赏
  • 举报
回复
up
cellblue 2003-11-05
  • 打赏
  • 举报
回复
你所执行的SQL语句最终是由Access来解析的,和bcp这个外部的命令没有关系

如果你要产生txt文件,完全可以把返回的记录集放在DataSet中,然后导出成txt
sharplee82 2003-11-05
  • 打赏
  • 举报
回复




我的意思是把做的这个小应用程序放到用户上运行的时候,当然也会把bcp这个命令拷到对方的c:\windows\system32目录下。这个命令不就可以用了吗?
但是如何在程序中用而不出错呢?
如果大家不知道,那如何要你把Access库中的表在程序中转换成.txt文本件,你是如何做的?
hyj122 2003-11-05
  • 打赏
  • 举报
回复
up
jp311 2003-11-05
  • 打赏
  • 举报
回复
恕我无知,竟然不知道bcp是什么东西:P
查了半天,也没没查出ACCESS能支持这个命令,ACCESS本来功能就不多
如果换成SQL SERVER做DB,应该可以支持
cellblue 2003-11-05
  • 打赏
  • 举报
回复
Dim commstring As String = "bcp '" + selectstring + "' queryout " & filename & ".txt"
无法执行这组成的SQL语句

cellblue 2003-11-05
  • 打赏
  • 举报
回复
Dim commstring As String = "bcp '" + selectstring + "' queryout " & filename & ".txt"
无法执行这语句
jp311 2003-11-05
  • 打赏
  • 举报
回复
commstring 是干什么的呀???
OleDbCommand只接受SQL语句
Dim sendtofilecomm As New OleDbCommand(selectstring, conn)
wjhs 2003-11-05
  • 打赏
  • 举报
回复
定义sendtofilecomm.SelectCommand,DeleteCommand,InsertCommand,UpdateCommand
之后在ExecuteNonQuery();
兵哥笑而不语 2003-11-05
  • 打赏
  • 举报
回复
这access里没有外部命令,不能倒出数据,这个只能在sqlserver里用
sharplee82 2003-11-05
  • 打赏
  • 举报
回复
http://developer.ccidnet.com/pub/article/c1137_a11405_p1.html
sharplee82 2003-11-05
  • 打赏
  • 举报
回复

怎么没有人回答了????????????
sharplee82 2003-11-05
  • 打赏
  • 举报
回复


to: guoyan19811021(吉祥)
我这是在windows窗体中。: )
guoyan19811021 2003-11-05
  • 打赏
  • 举报
回复
Dim conn As OleDb.OleDbConnection = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\db.mdb")
Dim cmd As OleDb.OleDbDataAdapter = New OleDb.OleDbDataAdapter("select * from 1", conn)
Dim dst As DataSet = New DataSet
cmd.Fill(dst)
Response.Charset = "UTF-8"
Response.AppendHeader("Content-Disposition", "attachment;filename=text.txt")
Response.ContentEncoding = System.Text.Encoding.Default
Dim tw As System.IO.StringWriter = New System.IO.StringWriter
Dim hw As Web.UI.HtmlTextWriter = New Web.UI.HtmlTextWriter(tw)
Dim i As Integer
Dim j As Integer
For i = 0 To dst.Tables(0).Rows.Count - 1
For j = 0 To dst.Tables(0).Columns.Count - 1
Response.Write(dst.Tables(0).Rows(i)(dst.Tables(0).Columns(j).ColumnName).ToString)
Response.Write(vbTab)
If j = dst.Tables(0).Columns.Count - 1 Then
Response.Write(vbCrLf)
End If
Next
Next
Response.End()
End Sub
jeall 2003-11-05
  • 打赏
  • 举报
回复
UP
sharplee82 2003-11-05
  • 打赏
  • 举报
回复


我导入文本文件的目录是,用户将会把这个文件带回到公司总部,在我们的装有SQLserver的电脑上然后将文本文件转换成vf2.6,如果大家能在代码中把某Access库中某表中查询的记录在程序中自动生成一个Access 库和一个表也可达到我的目的。有代码吗?谢谢了。
sharplee82 2003-11-05
  • 打赏
  • 举报
回复



你们不老是说啊。写出代码来看看?
cellblue 2003-11-05
  • 打赏
  • 举报
回复
如果你是导出成XML的话,可以直接使用DataSet导出,如果是txt的话,可能只能一行一行自己写了

DS.WriteXml("c:\\Temp.xml",System.Data.XmlWriteMode.WriteSchema);
gOODiDEA 2003-11-05
  • 打赏
  • 举报
回复
Access不支持Bcb吧,你可以考虑新建一个文本文件来写入

111,120

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧