Hello,

I am building an application and would like to use VBScript to do all the INSERT, SELECT, DELETE ect.

I am kind of stuck in how to attempt such a thing. I have done some code for it but don't know how to transfer the data from the VBScript to the MainForm and then populate the data in the correct fields.

There is doing it using DataAdapter, but this will be doing many SQL, so I will be using DataReader for all of the SQL statements.

I am open to suggestions.

Main Form
Code:
Public Class frmMain

    Dim dbCommands As New dbCommands

    Private Sub cmdSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSearch.Click
        Dim tableValue As String = ""

        If radCaseFile.Checked = True Then
            tableValue = "CaseFile"
        Else
            tableValue = "AWF"
        End If

        dbCommands.dbOpen()
        dbCommands.dbSearch(tableValue, txtCaseID.Text, txtFName.Text, txtSName.Text)
        dbCommands.dbClose()
    End Sub
End Class
VBScript Commands
Code:
Public Class dbCommands

    Dim dbConnection As New MySql.Data.MySqlClient.MySqlConnection
    Dim dbCommand As New MySql.Data.MySqlClient.MySqlCommand
    Dim dbReader As MySql.Data.MySqlClient.MySqlDataReader

    Public Sub dbOpen()
        dbConnection.ConnectionString = "Server='XXX'; Database=XXX'; Port=XXX;" & _
        "Uid='XXX; Password='XXX;"
        dbConnection.Open()
    End Sub

    Public Sub dbClose()
        dbConnection.Close()
    End Sub

    Public Function dbSearch(ByVal table As String, ByVal caseid As String, ByVal fname As String, ByVal sname As String)
        Dim strSQL As String = ""
        Dim dataTable As New Data.DataTable

        strSQL = "SELECT FirstName, Surname," & table & ".CaseID FROM " & table & ", Subjects WHERE " & _
        "Subjects.CaseID = " & table & ".CaseID "

        If Not caseid = "" And fname = "" And sname = "" Then
            If Not caseid = "" Then
                strSQL += "AND CaseID = '" & caseid & "'"
            End If

            If Not fname = "" Then
                strSQL += "AND FirstName = '" & fname & "'"
            End If

            If Not sname = "" Then
                strSQL += "AND Surname = '" & sname & "'"
            End If

            dbCommand.CommandText = strSQL
            dbCommand.CommandType = CommandType.Text
            dbReader = dbCommand.ExecuteReader()

        End If

        Return ??????

    End Function

End Class