Forum » Programiranje » [VB]Prosil bi za pomoč
[VB]Prosil bi za pomoč
mmaestro ::
Napisal sem sledečo kodo, ki pa mi ne deluje, ko pride do stavka Set objConn = Server.CreateObject("ADODB.Connection") v proceduri Insert mi javi Run-time error '424' Object required.
Kaj naj naredim da bo to delalo, kodo sem najdu na internetu in jo malo predelal tako da mislim da bi to moglo delovat.
Dodati bi verjeno mogu referenco sam ne vem katero oz nekje sem najdu da naj bi to bila Microsoft Active Server Pages Object Library tega pa sploh nimam na seznamu mojih referenc. Kdo ve kako priti do tega?
LP
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
Application.EnableEvents = False
If Target.Value >= 10 Then
'Range("F10").Value = True
Insert ("TRUE")
Else
'Range("F10").Value = False
Insert ("FALSE")
End If
Application.EnableEvents = True
End If
End Sub
Function Insert(strSql As String)
Dim objConn
Dim objComm
Set objConn = Server.CreateObject("ADODB.Connection")
Set objComm = Server.CreateObject("ADODB.Command")
objConn.Open "Provider=SQLOLEDB; Data Source=(local); Initial Catalog=Test; UId=user; Pwd=geslo"
objComm.ActiveConnection = objConn
objComm.CommandType = 1 'adCmdText
objComm.CommandText = "INSERT INTO Test VALUES (1, '" + strSql + "')"
'UPDATE authors SET au_lname = 'Smith' WHERE au_fname = 'Burt'"
objComm.Execute
End Function
Kaj naj naredim da bo to delalo, kodo sem najdu na internetu in jo malo predelal tako da mislim da bi to moglo delovat.
Dodati bi verjeno mogu referenco sam ne vem katero oz nekje sem najdu da naj bi to bila Microsoft Active Server Pages Object Library tega pa sploh nimam na seznamu mojih referenc. Kdo ve kako priti do tega?
LP
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
Application.EnableEvents = False
If Target.Value >= 10 Then
'Range("F10").Value = True
Insert ("TRUE")
Else
'Range("F10").Value = False
Insert ("FALSE")
End If
Application.EnableEvents = True
End If
End Sub
Function Insert(strSql As String)
Dim objConn
Dim objComm
Set objConn = Server.CreateObject("ADODB.Connection")
Set objComm = Server.CreateObject("ADODB.Command")
objConn.Open "Provider=SQLOLEDB; Data Source=(local); Initial Catalog=Test; UId=user; Pwd=geslo"
objComm.ActiveConnection = objConn
objComm.CommandType = 1 'adCmdText
objComm.CommandText = "INSERT INTO Test VALUES (1, '" + strSql + "')"
'UPDATE authors SET au_lname = 'Smith' WHERE au_fname = 'Burt'"
objComm.Execute
End Function
- spremenil: mmaestro ()
zavajon ::
mogoče bi za začetek pomagalo, da deklariraš variable kot objekte.
Dim objConn as Object
Dim objComm as Object
Če pa to slučajno delaš v VB-ju, bi bilo morda bolje referencirati ADODB, nato pa v kodi uporabiš
Dim objConn as new ADODB.Connection
Dim objComm as new ADODB.Command
lp
Dim objConn as Object
Dim objComm as Object
Če pa to slučajno delaš v VB-ju, bi bilo morda bolje referencirati ADODB, nato pa v kodi uporabiš
Dim objConn as new ADODB.Connection
Dim objComm as new ADODB.Command
lp
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | Shraniti XML string iz interneta na strežnik (ASP)Oddelek: Izdelava spletišč | 1967 (1863) | tejcek |
» | asp+access problemOddelek: Izdelava spletišč | 1078 (1009) | appz |
» | asp problem - noce updejtat bazeOddelek: Izdelava spletišč | 941 (884) | AglioAlio |
» | ASP in direktni query v MySQLOddelek: Programiranje | 1724 (1618) | BBB |
» | ASP in vnosni podatki v MDBOddelek: Izdelava spletišč | 1008 (919) | swalow |