Solved

Access a SQL database from a console application

Posted on 2012-04-09
1
229 Views
Last Modified: 2012-04-10
I am trying to create a console application to run robocopy and copy a folder structure and still keep the permissions.

I have most of it working except for accessing the data for the new folder names.  Which can either reside in a sql database or in an access database.

Examples of how to get this working would be great.  here is what i have so far.

Module Module1

    Sub Main()

        Dim MyDatabase As OleDb.OleDbConnection
        Dim ConnectToMyDatabase As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
             "Data Source=\\SERVER\Database.mdb"
        MyDatabase = New OleDb.OleDbConnection(ConnectToMyDatabase)
        MyDatabase.Open()
        Dim stringx As String
        stringx = MyDatabase.Table

        Dim file As String
        file = "robocopy.exe"

        Dim args As String
        args = "C:\test C:\test2 *.* /copyall /mir"

        Dim username As String
        username = "Username"

        Dim pass As SecureString
        pass = Secure()

        Dim Dom As String
        Dom = "DOMAIN"
        Stop

        'Process.Start(file, args, username, pass, Dom)


    End Sub

    Public Function Start(fileName As String, arguments As String, userName As String, password As SecureString, domain As String) As Process
    End Function

    Public Function Secure() As SecureString
        Dim pass As String
        pass = "password"
        Dim str As New SecureString
        For x As Integer = 0 To pass.Length - 1
            str.AppendChar(pass.Substring(x, 1))
        Next

        Return str
    End Function

End Module

Open in new window

0
Comment
Question by:mjelec
1 Comment
 
LVL 53

Accepted Solution

by:
Dhaest earned 500 total points
Comment Utility
Visual Basic 6 ADO Tutorial - reading mdb file
http://www.timesheetsmts.com/adotutorial.htm

 How to connect to a SQL server using Visual Basic 6.0
http://www.dreamincode.net/forums/topic/24677-connecting-to-a-sql-server-database-using-adodb/
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now