how to setup .exe with the following code

Module Module1

Sub Main()

Dim cn 'As New ADODB.Connection

Dim rs 'As New Recordset

Dim sSQL 'As String

Dim f 'As Integer

Try

cn = CreateObject("ADODB.Connection")

cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\SCM\fpdb\PTDB\MC30.mdb;Persist Security Info=False"

sSQL = "SELECT mc_tbl_calendar.ID, mc_tbl_calendar.fldNAME, mc_tbl_event.fldCAL_ID, mc_tbl_event.fldBYN, mc_tbl_event.fldEDATE, mc_tbl_event.fldSDATE"

sSQL = sSQL & " FROM mc_tbl_event LEFT JOIN mc_tbl_calendar ON mc_tbl_event.fldCAL_ID = mc_tbl_calendar.ID"

sSQL = sSQL & " WHERE (((mc_tbl_event.fldEDATE)>=(Now())) AND ((mc_tbl_event.fldSDATE)<=(Now())))"

' MsgBox(sSQL)

cn.open()

rs = cn.execute(sSQL)

 

rs.Close()

cn.Close()

Catch ex As Exception

'do something here if it barfs

End Try

End Sub

End Module

tmurray22Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics TeacherCommented:
Hi tmurray22,

Seems like a silly question to ask but...

Do you not have VB.Net or VB6 available to you?

The code you have posted looks like a mix of VBScript or VB6 code pasted into the body of a VB.Net module.

If you have VB.Net then create a new project, add a module, paste the code, change the startup object to Sub Main and compile...

tmurray22Author Commented:
I have VB6
Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics TeacherCommented:
For VB6...

Create a New Project and then click on Project --> Add Module --> Open.  Then paste the code:

' ----------------------------------------
' Module1
' ----------------------------------------
Public Sub Main()
    On Error GoTo Barf
   
    Dim cn As New ADODB.Connection
    Dim rs As New Recordset
    Dim sSQL As String
    Dim f As Integer

    cn = CreateObject("ADODB.Connection")

    cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\SCM\fpdb\PTDB\MC30.mdb;Persist Security Info=False"

    sSQL = "SELECT mc_tbl_calendar.ID, mc_tbl_calendar.fldNAME, mc_tbl_event.fldCAL_ID, mc_tbl_event.fldBYN, mc_tbl_event.fldEDATE, mc_tbl_event.fldSDATE"

    sSQL = sSQL & " FROM mc_tbl_event LEFT JOIN mc_tbl_calendar ON mc_tbl_event.fldCAL_ID = mc_tbl_calendar.ID"

    sSQL = sSQL & " WHERE (((mc_tbl_event.fldEDATE)>=(Now())) AND ((mc_tbl_event.fldSDATE)<=(Now())))"

    cn.Open

    rs = cn.execute(sSQL)

    rs.Close

    cn.Close
Exit Sub

Barf:
    'do something here if it barfs
End Sub

(I have no idea if that code is correct or not...I just converted it to VB6 syntax.)

Right click on Form1 in the Project explorer and select "Remove Form1".  Next, go to Project --> {Project1} Properties and set the "Startup Object:" to Sub Main.

Finally go to File --> Make {Project1.Exe} and select a location to make the exe file.

Hope that helps...

~IM

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BarshamDevelopment Team LeadCommented:
oh ! there is something in the end goto Project->References menu and choise "Microsoft ActiveX Data Object 2.5 Library" or higher Version

for DB Engine ;)
tmurray22Author Commented:
This code works as a script but when I try to remove the message box for automation I get an error

 Dim cn 'As New ADODB.Connection
    Dim rs 'As New Recordset
    Dim sSQL 'As String
    Dim f 'As Integer
    set cn = CreateObject("ADODB.Connection")
    cn.ConnectionString= "Provider=Microsoft.Jet.OLEDB.4.0;Data   Source=C:\Inetpub\wwwroot\SCM\fpdb\PTDB\MC30.mdb;Persist Security Info=False"
    sSQL = "SELECT mc_tbl_calendar.ID, mc_tbl_calendar.fldNAME, mc_tbl_event.fldCAL_ID, mc_tbl_event.fldBYN, mc_tbl_event.fldEDATE, mc_tbl_event.fldSDATE"
    sSQL = sSQL & " FROM mc_tbl_event LEFT JOIN mc_tbl_calendar ON mc_tbl_event.fldCAL_ID = mc_tbl_calendar.ID"
    sSQL = sSQL & " WHERE (((mc_tbl_event.fldEDATE)>=(Now())) AND ((mc_tbl_event.fldSDATE)<=(Now())))"

    msgbox sSQL
     cn.open
     Set rs = cn.execute(sSQL)
        If Not rs.EOF Then
            set fso = createobject("scripting.filesystemobject")
               set outfile = fso.createtextfile("C:\dilsysopen.txt")
             Do Until rs.EOF
                 outfile.writeline rs.Fields("fldNAME")
                 rs.MoveNext
            Loop
            outfile.close
        End If
        rs.Close
    cn.Close


Thanks
tmurray22
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.