如何将txt文件中的内容存入SQL数据库
txt文件格式如下:序号条码数量110011,12219910,11内容中和空格还不确定。怎样存入相应的字段内?谢谢大家了想了很久都没有想出来只好求助了!PrivateS...
txt文件格式如下:
序号 条码 数量
1 10011 , 12
2 19910 , 11
内容中和空格还不确定。
怎样存入相应的字段内?
谢谢大家了想了很久都没有想出来只好求助了!
Private Sub cmdOKA_Click()
Dim ReadFile As String
Dim FileNum As Long
Static I As Integer
Dim J, K As Integer
FileNum = FreeFile
Open "D:\080616.txt" For Input As FileNum
' K = 1
Do While Not EOF(FileNum)
Line Input #FileNum, ReadFile
Print ReadFile
' If I <> 0 Then Load txtText(I)
'
' txtText(I).Move 135, 200 + 500 * I
' txtText(I).Text = I
' txtText(I).Visible = True
' txtText(I) = txtText(I) & ReadFile
' J = InStr(K, txtText(I).Text, " ")
' Print Left$(txtText(0).Text, J)
' I = I + 1
' K = J
Loop
' J = InStr(J + 3, txtText(0).Text, " ")
' Print Left$(txtText(0).Text, J)
Close #1
End Sub 展开
序号 条码 数量
1 10011 , 12
2 19910 , 11
内容中和空格还不确定。
怎样存入相应的字段内?
谢谢大家了想了很久都没有想出来只好求助了!
Private Sub cmdOKA_Click()
Dim ReadFile As String
Dim FileNum As Long
Static I As Integer
Dim J, K As Integer
FileNum = FreeFile
Open "D:\080616.txt" For Input As FileNum
' K = 1
Do While Not EOF(FileNum)
Line Input #FileNum, ReadFile
Print ReadFile
' If I <> 0 Then Load txtText(I)
'
' txtText(I).Move 135, 200 + 500 * I
' txtText(I).Text = I
' txtText(I).Visible = True
' txtText(I) = txtText(I) & ReadFile
' J = InStr(K, txtText(I).Text, " ")
' Print Left$(txtText(0).Text, J)
' I = I + 1
' K = J
Loop
' J = InStr(J + 3, txtText(0).Text, " ")
' Print Left$(txtText(0).Text, J)
Close #1
End Sub 展开
2个回答
展开全部
/** 导入文本文件
EXEC master..xp_cmdshell 'bcp "dbname..tablename" in c:\DT.txt -c -Sservername -Usa -Ppassword'
/** 导出文本文件
EXEC master..xp_cmdshell 'bcp "dbname..tablename" out c:\DT.txt -c -Sservername -Usa -Ppassword'
或
EXEC master..xp_cmdshell 'bcp "Select * from dbname..tablename" queryout c:\DT.txt -c -Sservername -Usa -Ppassword'
EXEC master..xp_cmdshell 'bcp "dbname..tablename" in c:\DT.txt -c -Sservername -Usa -Ppassword'
/** 导出文本文件
EXEC master..xp_cmdshell 'bcp "dbname..tablename" out c:\DT.txt -c -Sservername -Usa -Ppassword'
或
EXEC master..xp_cmdshell 'bcp "Select * from dbname..tablename" queryout c:\DT.txt -c -Sservername -Usa -Ppassword'
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询