Help with Visual Studio 2008

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2008
Posts: 11
Reputation: Birdie010 is an unknown quantity at this point 
Solved Threads: 0
Birdie010 Birdie010 is offline Offline
Newbie Poster

Help with Visual Studio 2008

 
0
  #1
Dec 7th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 16,253
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 542
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator

Re: Help with Visual Studio 2008

 
0
  #2
Dec 7th, 2008
Birdie. Stop making loads of new threads. Just make each problem a new post.
If i am helpful, please give me reputation points.
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Help with Visual Studio 2008

 
0
  #3
Dec 7th, 2008
birdie also needs to figure out code tags in the worst possible way real soon now
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 2
Reputation: sumithakb is an unknown quantity at this point 
Solved Threads: 0
sumithakb sumithakb is offline Offline
Newbie Poster

Re: Help with Visual Studio 2008

 
0
  #4
Dec 8th, 2008
Originally Posted by Birdie010 View Post
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
how to connect a form in vb.net with the code
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC