Link to home
Start Free TrialLog in
Avatar of EDW_Gideon
EDW_GideonFlag for United States of America

asked on

Assistance w/ VB.Net data connection

I've taken over a project to convert a VB6 app into VB.Net, the application was started but not finished.  I'm very familiar w/ VB6 but not so familiar w/ VB.Net...  I've looked at DBProviderFactory on the MSDN site.  Essentially I'm getting by but the database connection process seems alien to me so I'm hoping that someone out there can help me get what I need to get done.  I'm trying to use this process to grant access permissions to tables and databases.  I'm just not sure how to simply execute the SQL and not return results. (other than success/failure)  I don't really understand how this connection works, it's much different than ADO in VB6, I can't seem to find an 'con.Execute' command.  Here's what I have thus far, I apologize for the potential mess you're about to see...  I've tried to piece together stuff the web and stuff that was entered by the previous dev to get the result I want:

If rblGrntRvk.SelectedValue = "0" Then
            'GRANT
            SqlQuery.Append("GRANT ")
            SqlQuery.Append(txtRights.Text.ToString)
            SqlQuery.Append(" ON ")
            SqlQuery.Append(txtObj.Text.ToString)
            SqlQuery.Append(" TO ")
            SqlQuery.Append(ddUsers.Text.ToString)
            SqlQuery.Append(";")
        Else
            'REVOKE
            SqlQuery.Append("REVOKE ")
            SqlQuery.Append(txtRights.Text.ToString)
            SqlQuery.Append(" ON ")
            SqlQuery.Append(txtObj.Text.ToString)
            SqlQuery.Append(" FROM ")
            SqlQuery.Append(ddUsers.Text.ToString)
            SqlQuery.Append(";")
        End If

        SelStmt = SqlQuery.ToString()

        Dim pf1 As DbProviderFactory = DbProviderFactories.GetFactory("Teradata.Client.Provider")
        Dim con1 As DbConnection = pf1.CreateConnection()

        sConnection = "Data Source=" + Session.Contents("DataSource") + ";User ID=" + Session.Contents("AdminLogin") + ";Password=" + Session.Contents("AdminPasswd")
        con1.ConnectionString = sConnection

        Try
            con1.Open()

            Dim command1 As DbCommand = pf1.CreateCommand
            command1.CommandText = SelStmt
            command1.CommandType = CommandType.Text

            Dim adapter As DbDataAdapter = pf1.CreateDataAdapter()
            adapter.SelectCommand = command1

        Catch ex As Exception

        Finally
        End Try
        Exit Sub
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial