Reading data from SQL

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jan 2008
Posts: 2
Reputation: Teder is an unknown quantity at this point 
Solved Threads: 0
Teder Teder is offline Offline
Newbie Poster

Reading data from SQL

 
0
  #1
Jan 4th, 2008
Hi all, I've been designing a program in VB6 to extract certain rows of data from a SQL Database and shoot them out over email. Problem is, the farthest I can get is to printing them on the VB form, and can't do much else. I get an error when I try to send the the data out over the Outlook script, claiming it doesn't support it. So I need someway to get this data into a more managable form before I email it. I'd also like to be able to display it in a text/label box rather than just the Print command.
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 538
Reputation: choudhuryshouvi is an unknown quantity at this point 
Solved Threads: 49
choudhuryshouvi's Avatar
choudhuryshouvi choudhuryshouvi is offline Offline
Posting Pro

Re: Reading data from SQL

 
0
  #2
Jan 5th, 2008
Originally Posted by Teder View Post
Hi all, I've been designing a program in VB6 to extract certain rows of data from a SQL Database and shoot them out over email. Problem is, the farthest I can get is to printing them on the VB form, and can't do much else. I get an error when I try to send the the data out over the Outlook script, claiming it doesn't support it. So I need someway to get this data into a more managable form before I email it. I'd also like to be able to display it in a text/label box rather than just the Print command.
I'm attaching an application that is capable in register users into a sql database and sending mails to them using each of the users email address. Check whether this application helps you to get your answer or not. I've used an USER-DSN connection to communicate with the back-end server and i've used Microsoft Sql Server 7.0 . I've assumed that you are already familier in how to create an user-dsn.

For your consideration i've also included the script file of the sql database that i'd used. But to proceed in working with the database you have to create a user login named "STUDENT" with password "STUDENT" using the sql server enterprise manager. I'm also assuming that you know how to create a security login in sql server. After extracting from the zip file, run the file "script.sql" using sql server query analyzer to create the table structure. Consider the file "DSN.txt" to see the connection string which the application uses.

For your consideration i've also attached two snapshots of the application. Plz check those out too.

Don't forget to know me your feedback.
I'm waiting to hear some good news from you.

Good Luck

Best Regards
Shouvik
Attached Thumbnails
Before sending mails.JPG   After sending mails.JPG  
Attached Files
File Type: zip VB-SqlDemo.zip (28.2 KB, 48 views)
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 2
Reputation: Teder is an unknown quantity at this point 
Solved Threads: 0
Teder Teder is offline Offline
Newbie Poster

Re: Reading data from SQL

 
0
  #3
Jan 8th, 2008
Thank you for the response, but in the end I just decided to store it in a label and then shoot it out. The code looks something like this:

Private Sub Command1_Click()
Dim MyConnObj As New ADODB.Connection
Dim myRecSet As New ADODB.Recordset
Rec = 1

'SQL Connection
MyConnObj.Open _
"Provider = sqloledb;" & _
"Data Source=FRISCH08\SQLEXPRESS;" & _
"Initial Catalog=WWALMDB;" & _
"User ID=sa;" & _
"Password=sqlpass;"

sqlStr = "select * from dbo.Events"

myRecSet.Open sqlStr, MyConnObj, adOpenKeyset

'EOF Non Looping
While Not myRecSet.EOF

If myRecSet(8) = 1 Then Label1 = myRecSet(4) & " , " & myRecSet(19)
Rec = 2

myRecSet.MoveNext

Wend

'Email Send
If Rec = 2 Then

Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApp.CreateItem(Outlookmailitem)

OutlookMail.To = "vrclan@gmail.com"
OutlookMail.Subject = "Alarm Notification"
OutlookMail.Body = Label1

OutlookMail.Send

Set OutlookMail = Nothing

Rec = 1

End If

End Sub

The program now successfuly scans the SQL database and sends an email if the conditions are met. I do have a new question now; is it possible to keep this program continously running to check the SQL database and see if any new tags have popped up matching the conditions?
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 538
Reputation: choudhuryshouvi is an unknown quantity at this point 
Solved Threads: 49
choudhuryshouvi's Avatar
choudhuryshouvi choudhuryshouvi is offline Offline
Posting Pro

Re: Reading data from SQL

 
0
  #4
Jan 9th, 2008
what did you mean by "tags"?
is it row in the table you are accessing???

you can use a timer object to accomplish this task.
call the procedure you've written to check the table for rows meeting a certain condition under the timer1_timer event and initialize the timer event from form_load.

hope this will do something good to you.

regards
Shouvik
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Reply With Quote Quick reply to this message  
Reply

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




Views: 2680 | Replies: 3
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC