Quantcast
Channel: Visual COBOL - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4356

Function to Create an ADO Connection

$
0
0

Let me start by saying that I'm very, very new to Visual COBOL.  I have been programming primarily in Visual Basic since version 3 (now VB 2013).  I have written many applications through the years for work, friends, and for myself.

I have downloaded the Visual COBOL v.2.2 Personal Edition from Micro Focus in attempts to learn from and to possibly help my coworker who is having a lot of trouble trying to learn Visual COBOL (purchased version). 


I would like to know how to take the following code (Visual Basic) from one of my classes in one of my projects and write it in Visual COBOL (again, personal edition):

Imports System.Data.SqlClient
Imports System
Imports System.IO
Imports System.Collections

Public Class LocalSQLDB

    Public Shared Function GetConnection() As SqlConnection
        Dim myConnStr As String = ""

        myConnStr = "Data Source=localhost\SQLEXPRESS;Initial Catalog=MyDatabase;Integrated Security=True"

        Return New SqlConnection(myConnStr)
    End Function

End Class

I tried to add a reference, System.Data.SqlClient, to my test application but it wasn't in the list for me to select.  I use this class / function to create my connection to my database being that I open my database / tables only when I need them and then close the connection.  I do this to prevent database corruption in the case of a power outage.  Users, in the past, have corrupted my database tables due to power outages. 

If anyone can assist me with this, then I'd greatly appreciated getting past this hurdle in my learning process.


Thanks.


Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>