Jump to content

Recommended Posts

Posted

Olá,

estou com problemas em executar uma make table query, que está numa bd access através de código VB.net. Basicamente nem sei por onde começar. Como é a maneira mais simples de o fazer?

Obrigado por qq ajuda.

Posted

Podes fazer algo do género, que basicamente executa um OleDBCommand e comando T-SQL não é mais do que um Exec à tua query (query1 no exemplo):

        Try

            Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\minhDB.mdb;"
            Using connection As New OleDb.OleDbConnection(connString)
                connection.Open()
                Using command As New OleDb.OleDbCommand("exec query1", connection)
                    command.ExecuteNonQuery()
                End Using
            End Using


        Catch ex As Exception
            MessageBox.Show(ex.Message, My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error)

        End Try
Posted

Simples e funcional. Já tinha tentado assim:

            Dim connString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\gespos2osCommerce\gespos2osCommerce.mdb;"
            Dim cmd As New System.Data.OleDb.OleDbCommand
            Dim connection As New OleDb.OleDbConnection(connString)
            cmd.CommandType = System.Data.CommandType.StoredProcedure
            cmd.CommandText = "Mk_Qry_Update_Price_Quantities"
            cmd.Connection = connection

e não funcionava mas aparentemente o problema estava na query, funcionava em access mas não através do VB e só consegui perceber com a tua linha

Catch ex As Exception

Obrigado pela ajuda!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.