Help me with the code or tutorial on how to connect vb .net with sql. dbase. thank you

Import the SqlClient first.

Then Establish the connection by

Sqlconnection conn=new Sqlconnection();
SqlCommand cmd=new SqlCommand("Query",conn);
cmd.ExecuteNonQuery();

A simple Insert Statement Function made by me for another project.

Function Insert(ByRef Conn As OleDbConnection, ByRef connection_string As String, ByRef Transaction As OleDbTransaction, ByRef ConnCommand As OleDbCommand, ByRef CommandText As String)
        Dim da As New OleDbDataAdapter

        Conn = New OleDbConnection(connection_string)

        Conn.Open()

        Transaction = Conn.BeginTransaction

        ConnCommand.Connection = Conn
        ConnCommand.Transaction = Transaction


        ConnCommand.CommandText = CommandText

        Try
            da.InsertCommand = ConnCommand
            da.InsertCommand.ExecuteNonQuery()

            Transaction.Commit()

            MessageBox.Show("Saved succesfully", "Adding Data", MessageBoxButtons.OK, MessageBoxIcon.Information)

        Catch ex As Exception

            Transaction.Rollback()
            MessageBox.Show(ex.Message)


        End Try

        Conn.Close()
        ConnCommand.Dispose()
        da.Dispose()
        Transaction.Dispose()

        Return Nothing
    End Function

Hope i helped!

This article has been dead for over six months. Start a new discussion instead.