我有连接,可以插入我的ms sql服务器。但是我该如何发送或插入一些文件(例如,file.rar)。我可以使用什么代码或参考,您可以解释一下。代码完全可以工作,但是我只发送字符串整数等。
Sub DbConnection()
Dim cn As ADODB.Connection
Set cn = New ADODB.Connection
Dim rs As ADODB.Recordset
Dim Authentication,ServerName,Database,UID,PASS As String
Dim strConn As String
'Authentication type EX : Windows Aut or SQL Server AUT
Authentication = "SQLOLEDB"
'Server Name ,Usualy Computer UID, I user MS SQL Express UID\SQLEXPRESS
ServerName = "DESKTOP-asfadgda\SQLEXPRESS"
'Creating Database Name
Database = "VBADB"
'User ID
UID = "sa"
'User Pass
PASS = "123"
'Connection String - Connection Link
strConn = "Provider=" &Authentication&";Data Source="&ServerName&";Initial Catalog="&Database&";User ID="&UID&";Password="&PASS&";"
cn.Open [strConn]
Dim strFirstName As String
Dim strSecondName As String
strFirstName = Trim(InputBox("Enter first name:"))
strSecondName = Trim(InputBox("Enter Surname:"))
Set rs = cn.Execute("INSERT INTO dbo.Table_2 (name, surname) VALUES (" & strFirstName & "," & strSecondName & ")")
cn.Close
Set cn = Nothing
MsgBox ("Congratulations")
End Sub