Jump to content

Adicionar na Base de dados via código(urgente)


Recommended Posts

No evento Page UnLoad inseres como por exemplo assim:

Dim strConn = "bla bla bla connection string"

Dim objConn As New SqlConnection(strConn)

        Dim objcmd As New SqlCommand
        objcmd.Connection = objConn
        Dim campo1 As New SqlParameter("@Codigo", OleDbType.VarChar)
        Dim campo2 As New SqlParameter("@Nome", OleDbType.VarChar)
        Dim campo3 As New SqlParameter("@Ch1", OleDbType.VarChar)
        Dim campo4 As New SqlParameter("@Função", OleDbType.VarChar)
        Dim campo5 As New SqlParameter("@Ch2", OleDbType.VarChar)
        Dim campo6 As New SqlParameter("@HE", OleDbType.VarChar)


        objcmd.Parameters(0).Value = textbox1.text
        objcmd.Parameters(1).Value = textbox2.text
        objcmd.Parameters(2).Value =textbox3.text
        objcmd.Parameters(3).Value = textbox4.text
        objcmd.Parameters(4).Value = textbox5.text
        objcmd.Parameters(5).Value = textbox6.text


There are two ways to write error-free programs; only the third one works.

Link to comment
Share on other sites

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.