troubleshooting Question

Assistance w/ VB.Net data connection

Avatar of EDW_Gideon
EDW_GideonFlag for United States of America asked on
.NET ProgrammingVisual Basic.NETMicrosoft Development
1 Comment1 Solution586 ViewsLast Modified:
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
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros