| | |
Help with Visual Studio 2008
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2008
Posts: 11
Reputation:
Solved Threads: 0
I'm receiving error message "Syntax error missing operator in query expression" any help you can provide is appreciated.
Private Sub btnEmailCat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEmailCat.Click
Dim SQLStmt, EmailAddress, SubjectLine, BodyText, CATDateString, DollarsAndCents, NoDecimal As String
Dim CATCounter As Integer
Dim GSIdNum, GSIdHash As Long
Dim Cnxn As New OleDbConnection( _
"Provider=Microsoft.JET.OLEDB.4.0;" _
& "Data Source=DB.mdb")
Cnxn.Open()
If Cnxn.State <> ConnectionState.Open Then
MsgBox("Unable to connect to the database...", MsgBoxStyle.Critical)
End
End If
SQLStmt = "SELECT Id, Descr, Price from GS WHERE Ledger = 4010"
Debug.Write("SQLStmt=" & SQLStmt)
Dim cmdSearch As New OleDbCommand(SQLStmt, Cnxn)
Dim CatEntries As OleDbDataReader = cmdSearch.ExecuteReader
If Not CatEntries.Read Then
MsgBox("No records were found with Ledger 4010")
Else
CATCounter = 0
GSIdHash = 0
CATDateString = Format(Now(), "yyyyMMddHHmmss")
EmailAddress = "ledgerengine@info465.net"
SubjectLine = "*!*!9999*" & CATDateString
BodyText = "CAT*9999*" & CATDateString & vbCrLf
Do
CATCounter += 1
DollarsAndCents = Format(CatEntries.Item("Price"), "0.00")
NoDecimal = Microsoft.VisualBasic.Left(DollarsAndCents, Len(DollarsAndCents) - 3) & _
Microsoft.VisualBasic.Right(DollarsAndCents, 2)
BodyText &= "ITEM*" & CatEntries.Item("Id") & "*" & CatEntries.Item("Descr") & _
"*" & NoDecimal & vbCrLf
GSIdNum = Val(CatEntries.Item("Id"))
GSIdHash += GSIdNum
Loop Until Not CatEntries.Read
BodyText &= "ECAT*" & CATCounter + 2 & "*" & GSIdHash
Dim TheEmail As New System.Net.Mail.MailMessage
TheEmail.To.Add("gs9191@info465.net")
TheEmail.From = New MailAddress("1spice@vcu.edu")
TheEmail.Subject = SubjectLine
MsgBox("Body Text =" & BodyText)
TheEmail.Body = BodyText
Dim SMTPClient As New SmtpClient("mail1.vcu.edu")
'SmtpServer = "mail1.vcu.edu"
SMTPClient.Send(TheEmail)
MsgBox("Got " & CATCounter & " records back..." & vbCrLf & SubjectLine & vbCrLf & BodyText)
End If
Cnxn.Close()
End Sub
End Class
Private Sub btnEmailCat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEmailCat.Click
Dim SQLStmt, EmailAddress, SubjectLine, BodyText, CATDateString, DollarsAndCents, NoDecimal As String
Dim CATCounter As Integer
Dim GSIdNum, GSIdHash As Long
Dim Cnxn As New OleDbConnection( _
"Provider=Microsoft.JET.OLEDB.4.0;" _
& "Data Source=DB.mdb")
Cnxn.Open()
If Cnxn.State <> ConnectionState.Open Then
MsgBox("Unable to connect to the database...", MsgBoxStyle.Critical)
End
End If
SQLStmt = "SELECT Id, Descr, Price from GS WHERE Ledger = 4010"
Debug.Write("SQLStmt=" & SQLStmt)
Dim cmdSearch As New OleDbCommand(SQLStmt, Cnxn)
Dim CatEntries As OleDbDataReader = cmdSearch.ExecuteReader
If Not CatEntries.Read Then
MsgBox("No records were found with Ledger 4010")
Else
CATCounter = 0
GSIdHash = 0
CATDateString = Format(Now(), "yyyyMMddHHmmss")
EmailAddress = "ledgerengine@info465.net"
SubjectLine = "*!*!9999*" & CATDateString
BodyText = "CAT*9999*" & CATDateString & vbCrLf
Do
CATCounter += 1
DollarsAndCents = Format(CatEntries.Item("Price"), "0.00")
NoDecimal = Microsoft.VisualBasic.Left(DollarsAndCents, Len(DollarsAndCents) - 3) & _
Microsoft.VisualBasic.Right(DollarsAndCents, 2)
BodyText &= "ITEM*" & CatEntries.Item("Id") & "*" & CatEntries.Item("Descr") & _
"*" & NoDecimal & vbCrLf
GSIdNum = Val(CatEntries.Item("Id"))
GSIdHash += GSIdNum
Loop Until Not CatEntries.Read
BodyText &= "ECAT*" & CATCounter + 2 & "*" & GSIdHash
Dim TheEmail As New System.Net.Mail.MailMessage
TheEmail.To.Add("gs9191@info465.net")
TheEmail.From = New MailAddress("1spice@vcu.edu")
TheEmail.Subject = SubjectLine
MsgBox("Body Text =" & BodyText)
TheEmail.Body = BodyText
Dim SMTPClient As New SmtpClient("mail1.vcu.edu")
'SmtpServer = "mail1.vcu.edu"
SMTPClient.Send(TheEmail)
MsgBox("Got " & CATCounter & " records back..." & vbCrLf & SubjectLine & vbCrLf & BodyText)
End If
Cnxn.Close()
End Sub
End Class
•
•
Join Date: Dec 2008
Posts: 2
Reputation:
Solved Threads: 0
•
•
•
•
I'm receiving error message "Syntax error missing operator in query expression" any help you can provide is appreciated.
Private Sub btnEmailCat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEmailCat.Click
Dim SQLStmt, EmailAddress, SubjectLine, BodyText, CATDateString, DollarsAndCents, NoDecimal As String
Dim CATCounter As Integer
Dim GSIdNum, GSIdHash As Long
Dim Cnxn As New OleDbConnection( _
"Provider=Microsoft.JET.OLEDB.4.0;" _
& "Data Source=DB.mdb")
Cnxn.Open()
If Cnxn.State <> ConnectionState.Open Then
MsgBox("Unable to connect to the database...", MsgBoxStyle.Critical)
End
End If
SQLStmt = "SELECT Id, Descr, Price from GS WHERE Ledger = 4010"
Debug.Write("SQLStmt=" & SQLStmt)
Dim cmdSearch As New OleDbCommand(SQLStmt, Cnxn)
Dim CatEntries As OleDbDataReader = cmdSearch.ExecuteReader
If Not CatEntries.Read Then
MsgBox("No records were found with Ledger 4010")
Else
CATCounter = 0
GSIdHash = 0
CATDateString = Format(Now(), "yyyyMMddHHmmss")
EmailAddress = "ledgerengine@info465.net"
SubjectLine = "*!*!9999*" & CATDateString
BodyText = "CAT*9999*" & CATDateString & vbCrLf
Do
CATCounter += 1
DollarsAndCents = Format(CatEntries.Item("Price"), "0.00")
NoDecimal = Microsoft.VisualBasic.Left(DollarsAndCents, Len(DollarsAndCents) - 3) & _
Microsoft.VisualBasic.Right(DollarsAndCents, 2)
BodyText &= "ITEM*" & CatEntries.Item("Id") & "*" & CatEntries.Item("Descr") & _
"*" & NoDecimal & vbCrLf
GSIdNum = Val(CatEntries.Item("Id"))
GSIdHash += GSIdNum
Loop Until Not CatEntries.Read
BodyText &= "ECAT*" & CATCounter + 2 & "*" & GSIdHash
Dim TheEmail As New System.Net.Mail.MailMessage
TheEmail.To.Add("gs9191@info465.net")
TheEmail.From = New MailAddress("1spice@vcu.edu")
TheEmail.Subject = SubjectLine
MsgBox("Body Text =" & BodyText)
TheEmail.Body = BodyText
Dim SMTPClient As New SmtpClient("mail1.vcu.edu")
'SmtpServer = "mail1.vcu.edu"
SMTPClient.Send(TheEmail)
MsgBox("Got " & CATCounter & " records back..." & vbCrLf & SubjectLine & vbCrLf & BodyText)
End If
Cnxn.Close()
End Sub
End Class
![]() |
Similar Threads
- Visual Studio FTP problems - FTP doesn't work (Windows NT / 2000 / XP)
- visual studio 2008 pocket pc windows 2002 (Windows Software)
- VB 6 or Visual Studio 2008 Express (VB.NET)
- Learning visual studio 2008 (C++)
- Visual Studio 2008 Form Designer Issues (VB.NET)
- WPF Grid with Visual Studio 2008 (VB.NET)
- Visual Studio 2008 Data Source Selection (ASP.NET)
- read/write files using visual studio 2009 (VB.NET)
- ifstream and ofstrem problem with visual studio 2008 (C++)
Other Threads in the VB.NET Forum
- Previous Thread: variable scope and choose statement help.
- Next Thread: deleting the records of the MS access table using VB.NET
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net 2005 2008 access account application arithmetic array arrays basic bing button buttons c# center check checkbox code combobox component convert crystalreport data database datagrid datagridview date dissertation dissertations dropdownlist excel fade file-dialog ftp generatetags google gridview hardcopy images inline input insert intel internet listview mobile monitor ms net networking objects output passingparameters peertopeervideostreaming picturebox picturebox1 port print printing problem problemwithinstallation project remove save searchbox searchvb.net select serial server shutdown soap sorting survey table tcp temperature text textbox timer toolbox trim update updown user validation vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web winforms wpf






