ERRO RUN TIME 13
Amigos sou novato em Vb e to com um problema tenho um codigo para leitor rfid e preciso gravar no banco de dados, os dados capturados e não estou conseguindo. Gostaria da ajuda de vcs.
Option Explicit
[ô]Example 6
[ô]
[ô]Working w/Tag Lists. Get a taglist from the reader as a string
[ô]and use the built-in parsing functions to turn the string into
[ô]a more developer-friendly data structure.
[ô]
[ô]Be sure to include a reference to the [Ô]Alien API for RFID[Ô] (AlienRFID1.tlb)
[ô]and specify your Com port number and/or your reader[ô]s IPAddress + Command port.
[ô]
[ô]Copyright © 2006 Alien Technology Corporation. All rights reserved.
[ô]
Dim WithEvents Reader As clsReader
Dim Settings As ReaderInfo
Dim msTagList As String
Dim mbAuto As Boolean
Dim mbClosing As Boolean
Private Sub btnGetTags_Click()
Call GetTags
End Sub
[ô]Private Sub btnParse_Click()
[ô] Call ParseTagList
[ô]End Sub
Private Sub Form_Load()
If Not mbClosing Then
Set Settings = New ReaderInfo
[ô]
With Settings
[ô] Network connection
.InterfaceType = ComInterface_enumTCPIP
.ipaddress = [Ô]127.0.0.1[Ô]
.TelnetPort = 23
[ô] [ô] OR for serial connection
[ô] .InterfaceType = ComInterface_enumSerial
[ô] .ComPort = 8
End With
Set Reader = New clsReader
Reader.ComTimeOutInterval = 100000
Reader.WriteSettings Settings
Debug.Print Reader.Connect
If Settings.InterfaceType = ComInterface_enumTCPIP Then
Debug.Print Reader.Login([Ô]alien[Ô], [Ô]password[Ô])
End If
Me.Caption = [Ô]Connected = [Ô] & Reader.IsConnected
If Not Reader.IsConnected Then
optAuto.Enabled = False
Else
Reader.AutoMode = [Ô]On[Ô]
Reader.TagListFormat = [Ô]Text[Ô]
End If
End If
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
optManual.Value = True
optManual_Click
If Not Reader Is Nothing Then
If Reader.IsConnected Then Reader.AutoMode = [Ô]Off[Ô]
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
mbClosing = True
If Not Reader Is Nothing Then
Reader.Disconnect
Set Reader = Nothing
End If
DoEvents
End Sub
Private Sub optAuto_Click()
If Not Reader Is Nothing And Not mbClosing Then
mbAuto = optAuto.Value
If mbAuto Then
btnGetTags.Enabled = False
btnParse.Enabled = True
End If
While mbAuto And Not mbClosing
Call GetTags
Call ParseTagList
DoEvents
Wend
If Not mbClosing Then
btnGetTags.Enabled = True
btnParse.Enabled = True
End If
End If
End Sub
Private Sub optManual_Click()
mbAuto = Not optManual.Value
End Sub
Private Sub Reader_MessageReceived(ByVal data As String)
If Not mbClosing Then
Text1.Text = Text1.Text & data
End If
End Sub
Private Sub GetTags()
If Not mbClosing Then
Screen.MousePointer = vbHourglass
If Reader.IsConnected Then
msTagList = Reader.TagList
Text1.Text = msTagList
Else
MsgBox [Ô]Not Connected[Ô]
End If
DoEvents
Screen.MousePointer = vbDefault
End If
End Sub
Private Sub ParseTagList()
Dim t() As TagInfo
Dim i As Integer
Dim bParseResult As Boolean
If Not mbClosing Then
myGrid.Rows = 1
Screen.MousePointer = vbHourglass
bParseResult = Reader.ParseTagList(msTagList, t)
If (bParseResult) Then
myGrid.FixedCols = 0
myGrid.FormatString = [Ô]^TagID |^LastSeenTime |^entrada |^ReadCount |^Antenna [Ô]
For i = 0 To UBound(t)
myGrid.AddItem (t(i).TagID & vbTab & _
t(i).LastSeenTime & vbTab & _
t(i).DiscoveryTime & vbTab & _
t(i).ReadCount & vbTab & _
t(i).Antenna)
Next
myGrid.ColWidth(-1) = myGrid.Width / 4 - 30
lblStatus.Caption = i & [Ô] tags found.[Ô]
Else
lblStatus.Caption = [Ô]Can[ô]t parse tag list.[Ô]
End If
myGrid.Refresh
Screen.MousePointer = vbDefault
End If
Dim linha As Integer
Dim cnn As New adodb.Connection
For linha = 1 To myGrid.Rows - 1
If Len(myGrid.TextMatrix(linha, 0)) <> 0 Then [ô] verifica se a primeira coluna da linha possui conteúdo, somente neste caso iremos gravar os dados
cnn.Execute [Ô]SQL=insert into monitora (Cracha, Saida, Entrada, Setor) values ([Ô] & CLng(myGrid.TextMatrix(linha, 0)) & [Ô],[ô][Ô] & myGrid.TextMatrix(linha, 1) & [Ô][ô],[ô][Ô] & myGrid.TextMatrix(linha, 2) & [Ô][ô],[ô][Ô] & myGrid.TextMatrix(linha, 4) & [Ô][ô])[Ô]
End If
Next
Exit Sub
errHandler:
Debug.Print Err.Description
Debug.Print msTagList
Debug.Print
Screen.MousePointer = vbDefault
End Sub
Option Explicit
[ô]Example 6
[ô]
[ô]Working w/Tag Lists. Get a taglist from the reader as a string
[ô]and use the built-in parsing functions to turn the string into
[ô]a more developer-friendly data structure.
[ô]
[ô]Be sure to include a reference to the [Ô]Alien API for RFID[Ô] (AlienRFID1.tlb)
[ô]and specify your Com port number and/or your reader[ô]s IPAddress + Command port.
[ô]
[ô]Copyright © 2006 Alien Technology Corporation. All rights reserved.
[ô]
Dim WithEvents Reader As clsReader
Dim Settings As ReaderInfo
Dim msTagList As String
Dim mbAuto As Boolean
Dim mbClosing As Boolean
Private Sub btnGetTags_Click()
Call GetTags
End Sub
[ô]Private Sub btnParse_Click()
[ô] Call ParseTagList
[ô]End Sub
Private Sub Form_Load()
If Not mbClosing Then
Set Settings = New ReaderInfo
[ô]
With Settings
[ô] Network connection
.InterfaceType = ComInterface_enumTCPIP
.ipaddress = [Ô]127.0.0.1[Ô]
.TelnetPort = 23
[ô] [ô] OR for serial connection
[ô] .InterfaceType = ComInterface_enumSerial
[ô] .ComPort = 8
End With
Set Reader = New clsReader
Reader.ComTimeOutInterval = 100000
Reader.WriteSettings Settings
Debug.Print Reader.Connect
If Settings.InterfaceType = ComInterface_enumTCPIP Then
Debug.Print Reader.Login([Ô]alien[Ô], [Ô]password[Ô])
End If
Me.Caption = [Ô]Connected = [Ô] & Reader.IsConnected
If Not Reader.IsConnected Then
optAuto.Enabled = False
Else
Reader.AutoMode = [Ô]On[Ô]
Reader.TagListFormat = [Ô]Text[Ô]
End If
End If
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
optManual.Value = True
optManual_Click
If Not Reader Is Nothing Then
If Reader.IsConnected Then Reader.AutoMode = [Ô]Off[Ô]
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
mbClosing = True
If Not Reader Is Nothing Then
Reader.Disconnect
Set Reader = Nothing
End If
DoEvents
End Sub
Private Sub optAuto_Click()
If Not Reader Is Nothing And Not mbClosing Then
mbAuto = optAuto.Value
If mbAuto Then
btnGetTags.Enabled = False
btnParse.Enabled = True
End If
While mbAuto And Not mbClosing
Call GetTags
Call ParseTagList
DoEvents
Wend
If Not mbClosing Then
btnGetTags.Enabled = True
btnParse.Enabled = True
End If
End If
End Sub
Private Sub optManual_Click()
mbAuto = Not optManual.Value
End Sub
Private Sub Reader_MessageReceived(ByVal data As String)
If Not mbClosing Then
Text1.Text = Text1.Text & data
End If
End Sub
Private Sub GetTags()
If Not mbClosing Then
Screen.MousePointer = vbHourglass
If Reader.IsConnected Then
msTagList = Reader.TagList
Text1.Text = msTagList
Else
MsgBox [Ô]Not Connected[Ô]
End If
DoEvents
Screen.MousePointer = vbDefault
End If
End Sub
Private Sub ParseTagList()
Dim t() As TagInfo
Dim i As Integer
Dim bParseResult As Boolean
If Not mbClosing Then
myGrid.Rows = 1
Screen.MousePointer = vbHourglass
bParseResult = Reader.ParseTagList(msTagList, t)
If (bParseResult) Then
myGrid.FixedCols = 0
myGrid.FormatString = [Ô]^TagID |^LastSeenTime |^entrada |^ReadCount |^Antenna [Ô]
For i = 0 To UBound(t)
myGrid.AddItem (t(i).TagID & vbTab & _
t(i).LastSeenTime & vbTab & _
t(i).DiscoveryTime & vbTab & _
t(i).ReadCount & vbTab & _
t(i).Antenna)
Next
myGrid.ColWidth(-1) = myGrid.Width / 4 - 30
lblStatus.Caption = i & [Ô] tags found.[Ô]
Else
lblStatus.Caption = [Ô]Can[ô]t parse tag list.[Ô]
End If
myGrid.Refresh
Screen.MousePointer = vbDefault
End If
Dim linha As Integer
Dim cnn As New adodb.Connection
For linha = 1 To myGrid.Rows - 1
If Len(myGrid.TextMatrix(linha, 0)) <> 0 Then [ô] verifica se a primeira coluna da linha possui conteúdo, somente neste caso iremos gravar os dados
cnn.Execute [Ô]SQL=insert into monitora (Cracha, Saida, Entrada, Setor) values ([Ô] & CLng(myGrid.TextMatrix(linha, 0)) & [Ô],[ô][Ô] & myGrid.TextMatrix(linha, 1) & [Ô][ô],[ô][Ô] & myGrid.TextMatrix(linha, 2) & [Ô][ô],[ô][Ô] & myGrid.TextMatrix(linha, 4) & [Ô][ô])[Ô]
End If
Next
Exit Sub
errHandler:
Debug.Print Err.Description
Debug.Print msTagList
Debug.Print
Screen.MousePointer = vbDefault
End Sub
em que linha é apontado o erro
cnn.Execute [Ô]SQL=insert into monitora (Cracha, Saida, Entrada, Setor) values ([Ô] & CLng(myGrid.TextMatrix(linha, 0)) & [Ô],[ô][Ô] & myGrid.TextMatrix(linha, 1) & [Ô][ô],[ô][Ô] & myGrid.TextMatrix(linha, 2) & [Ô][ô],[ô][Ô] & myGrid.TextMatrix(linha, 4) & [Ô][ô])[Ô]
o erro está aqui
cnn.Execute [Ô][txt-color=#e80000]SQL=[/txt-color]insert into monitora (Cracha, Saida, Entrada, Setor) values ([Ô] & CLng(myGrid.TextMatrix(linha, 0)) & [Ô],[ô][Ô] & myGrid.TextMatrix(linha, 1) & [Ô][ô],[ô][Ô] & myGrid.TextMatrix(linha, 2) & [Ô][ô],[ô][Ô] & myGrid.TextMatrix(linha, 4) & [Ô][ô])[Ô]
ou seja SQL= dentro da string não existe
é assim
cnn.Execute [Ô][txt-color=#e80000]SQL=[/txt-color]insert into monitora (Cracha, Saida, Entrada, Setor) values ([Ô] & CLng(myGrid.TextMatrix(linha, 0)) & [Ô],[ô][Ô] & myGrid.TextMatrix(linha, 1) & [Ô][ô],[ô][Ô] & myGrid.TextMatrix(linha, 2) & [Ô][ô],[ô][Ô] & myGrid.TextMatrix(linha, 4) & [Ô][ô])[Ô]
ou seja SQL= dentro da string não existe
é assim
cnn.Execute [Ô]insert into monitora (Cracha, Saida, Entrada, Setor) values ([Ô] & CLng(myGrid.TextMatrix(linha, 0)) & [Ô],[ô][Ô] & myGrid.TextMatrix(linha, 1) & [Ô][ô],[ô][Ô] & myGrid.TextMatrix(linha, 2) & [Ô][ô],[ô][Ô] & myGrid.TextMatrix(linha, 4) & [Ô][ô])[Ô]
Retirei o SQL= e o erro continua na mesma linha.
meu banco e .mdb tem algum problema com isso ?
meu banco e .mdb tem algum problema com isso ?
vc declarou a conexão(cnn) em um módulo?
Amigo pra falar a verdade não sei, pois este é meu primeiro sistema em vb. este fonte veio acompanhando um kit RFID que comprei, mais ele só ler as e mosntra, não grava eu queria gravar. vc pode me ajudar nisso. Ficarei muito grato.
desculpe eu não havia visto o cnn declarado
desconsidere a ultima mensagem, não estou entendendo o erro, tudo parece normal
desconsidere a ultima mensagem, não estou entendendo o erro, tudo parece normal
tente
cnn.Execute [Ô]insert into monitora (Cracha, Saida, Entrada, Setor) values ([Ô] & CLng(myGrid.TextMatrix(myGrid.row, 0)) & [Ô],[ô][Ô] & myGrid.TextMatrix(myGrid.row, 1) & [Ô][ô],[ô][Ô] & myGrid.TextMatrix(myGrid.row, 2) & [Ô][ô],[ô][Ô] & myGrid.TextMatrix(myGrid.row, 4) & [Ô][ô])[Ô]
Amigo obrigado pelas informações, o erro ainda continua acho que vou desistir e tentar outro sistema.
Tópico encerrado , respostas não são mais permitidas