| | |
Reading data from SQL
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jan 2008
Posts: 2
Reputation:
Solved Threads: 0
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.
•
•
•
•
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.
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
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Have a problem? Don't worry just give me a call and I'll fix it for you.
•
•
Join Date: Jan 2008
Posts: 2
Reputation:
Solved Threads: 0
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?
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?
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
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.
Have a problem? Don't worry just give me a call and I'll fix it for you.
![]() |
Similar Threads
- Reading and Displaying a comma delimited text file to a table. (ASP)
- Altering data when reading it from a database (MS SQL)
- SQL Server, Images and DataGrid in ASP.NET (ASP.NET)
- radio button ASP question?? (ASP)
- Remove quotation marks from a CSV file (C#)
- Perl/CGI (Saving Data) Part III (Computer Science)
- Working with SQL's Text data type (ASP.NET)
- clustering (Windows NT / 2000 / XP)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Error 998 in VB6 on Vista Home Premium
- Next Thread: win32 exception unhandled
Views: 2680 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex add age append application basic beginner birth bmp c++ calculator cd cells.find click client code college column component connection copy creat ctrl+f data database datareport date delete dissertations dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver struct subroutine table tags textbox time timer urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





