我主要有两个地方不明白。
1)如何连接SQL SERVER。我的机器名是“LI”,数据库名“HK”,表名“Temp”。
2)如何运行SQL语句?例如要运行“Insert into Temp (Desc,Cont) values("description","Content")”谢谢。
1)如何连接SQL SERVER。我的机器名是“LI”,数据库名“HK”,表名“Temp”。
2)如何运行SQL语句?例如要运行“Insert into Temp (Desc,Cont) values("description","Content")”谢谢。
并将后边的RS.close取掉,就可以了
"server=" & LI & ";uid="";pwd="";database="HK"”字体是红色,是不是有错啊。
strConnstring = "driver={SQL Server};" & _
"server=" & LI & ";uid="";pwd="";database=PMis"
private sub form_load()
dim g_cn As New ADODB.Connection
dim strsql as string
If g_cn.State = adStateOpen Then g_cn.Close
With g_cn
.Provider = "sqloledb"
.ConnectionString = "data source=L1;initial catalog=HK;user id=sa;password="
.Open
End With
strsql="Insert into Temp (Desc,Cont) values('description','Content')"
'插入新數據
g_cn.execute(strsql)
end sub
string ="Insert into Temp (Desc,Cont) values("description","Content")""