Meng-attach Database SQL Server Tanpa Disertai File Ldf

gilokomputerDatabase pada SQL Server terdiri dari dua file yaitu file datanya (yang disimpan dengan ekstensi .MDF) dan file log-nya (yang disimpan dengan ekstensi .LDF). Jika kita meng-attach suatu database melalui Enterprise Manager maka perlu menyertakan kedua file tersebut. Bagaimanakah jika kita hanya memiliki file .MDF nya saja?
Caranya mudah sekali, pada SQL Server terdapat stored procedure sp_attach_single_file_db. Stored procedure ini memang digunakan untuk meng-attach database yang hanya file data-nya saja (.MDF nya saja). Stored procedure ini memiliki dua buah parameter yaitu @dbname dan @physname. Parameter @dbname digunakan sebagai nama database yang hendak di-attach ke server sedangkan parameter @physname adalah nama fisik database (.MDF nya) termasuk path nya.
Sintaks dari stored procedure ini adalah sebagai berikut:
sp_attach_single_file_db [ @dbname = ] ‘dbname’, [ @physname = ] ‘physical_name’
Pada saat Anda menjalankan stored procedure ini disertai dengan database yang hendak Anda attach maka secara otomatis SQL Server akan membuat file log (.LDF) yang baru. Cara ini juga banyak digunakan oleh orang lain untuk memperkecil ukuran dari log file SQL Server.
Berikut ini adalah contoh penggunaan stored procedure sp_attach_single_file_db. Misalnya Anda memiliki database yang bernama db_databarang dengan nama file fisik c:\sqlsvr\data\databrg.mdf. Maka perintah untuk meng-attach database tersebut adalah seperti di bawah ini.
sp_attach_single_file_db @dbname = ‘db_databarang’, @physname = ‘c:\sqlsvr\data\databrg.mdf’
Demikianlah tips singkat seputar SQL Server ini. Semoga bermanfaat bagi Anda semua. Special thanks to Esa Ivani for love and support. Segala macam kritik dan saran bisa dikirimkan melalui sony-ak@sony-ak.com. Untuk melihat tulisan menarik lainnya silakan kunjungi http://www.sony-ak.com/.
Terimakasih.

Posted in Database (SQL SERVER, MYSQL etc) | Leave a comment

Berpindah Kolom pada baris yang sama di datagridview

IMG_1313

Default Penekanan key enter pada Datagrid adalah pindah baris di kolom yg sama sekarang kita mau membikin pindah pada baris yg sama pada kolom yg berbeda :

Public Class ClassMyGrid
Inherits System.Windows.Forms.DataGridView
Public IdxRow As SByte
Public IdxCol As SByte

Sub lanjut()
IdxRow = Me.CurrentCell.RowIndex – 1
IdxCol = Me.CurrentCell.ColumnIndex
End Sub

Private Sub dg_CellEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles Me.CellEnter
lanjut()
End Sub

Private Sub Datagridview1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
If e.KeyCode = Keys.Enter And IdxCol < Me.ColumnCount – 1 Then
Me.CurrentCell = Me(IdxCol + 1, IdxRow)
Else
Me.CurrentCell = Me(0, IdxRow + 1)
End If
End Sub
End Class

Posted in Pemerograman Visual Basic.net | 2 Comments

Menginstall Microsoft SQL Server 2005 Express

IMG_0781

When you try to connect to an instance of Microsoft SQL Server 2005 from a remote computer, you may receive an error message. Bila Anda mencoba untuk terhubung ke sebuah contoh dari Microsoft SQL Server 2005 dari komputer remote, Anda dapat menerima pesan kesalahan. This problem may occur when you use any program to connect to SQL Server. Masalah ini mungkin terjadi ketika Anda menggunakan program untuk melakukan koneksi ke SQL Server. For example, you receive the following error message when you use the SQLCMD utility to connect to SQL Server: Misalnya, Anda menerima pesan kesalahan berikut ketika Anda menggunakan SQLCMD utilitas untuk koneksi ke SQL Server:

Sqlcmd: Error: Microsoft SQL Native Client: An error has occurred while establishing a connection to the server. Sqlcmd: Kesalahan: Microsoft SQL Native Klien: Sebuah kesalahan telah terjadi ketika membangun koneksi ke server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. Saat melakukan koneksi ke SQL Server 2005, kegagalan ini dapat disebabkan oleh fakta bahwa di bawah pengaturan standar SQL Server tidak mengizinkan koneksi remote.

This problem may occur when SQL Server 2005 is not configured to accept remote connections. Masalah ini mungkin terjadi ketika SQL Server 2005 adalah tidak dikonfigurasi agar menerima koneksi jauh. By default, SQL Server 2005 Express Edition and SQL Server 2005 Developer Edition do not allow remote connections. Secara default, SQL Server 2005 Express Edition dan SQL Server 2005 Developer Edition tidak mengizinkan koneksi remote. To configure SQL Server 2005 to allow remote connections, complete all the following steps: Untuk mengkonfigurasi SQL Server 2005 untuk mengizinkan koneksi remote, melengkapi semua langkah-langkah berikut:

Enable remote connections on the instance of SQL Server that you want to connect to from a remote computer. Aktifkan koneksi jauh pada contoh dari SQL Server yang Anda ingin terhubung ke komputer dari jarak jauh.
Turn on the SQL Server Browser service. Mengaktifkan layanan SQL Server Browser.
Configure the firewall to allow network traffic that is related to SQL Server and to the SQL Server Browser service. Konfigurasi firewall untuk membolehkan jaringan lalu lintas yang berhubungan dengan SQL Server dan SQL Server untuk layanan browser.

This article describes how to complete each of these steps. Artikel ini menjelaskan bagaimana untuk menyelesaikan setiap langkah. Back to the top Kembali ke atas

MORE INFORMATION INFORMASI

To enable remote connections on the instance of SQL Server 2005 and to turn on the SQL Server Browser service, use the SQL Server 2005 Surface Area Configuration tool. Untuk mengaktifkan sambungan remote pada contoh dari SQL Server 2005 dan untuk mengaktifkan SQL Server Browser layanan, menggunakan SQL Server 2005 Permukaan Kawasan Konfigurasi alat. The Surface Area Configuration tool is installed when you install SQL Server 2005. Permukaan di Kawasan Konfigurasi alat terinstal ketika anda menginstal SQL Server 2005. Back to the top Kembali ke atas

Enable remote connections for SQL Server 2005 Express or SQL Server 2005 Developer Edition Mengaktifkan sambungan remote untuk SQL Server 2005 Express atau SQL Server 2005 Developer Edition

You must enable remote connections for each instance of SQL Server 2005 that you want to connect to from a remote computer. To do this, follow these steps: Anda harus mengaktifkan sambungan remote untuk setiap instance dari SQL Server 2005 yang Anda ingin terhubung ke komputer dari jarak jauh. Untuk melakukannya, ikuti langkah berikut:

1. Click Start , point to Programs , point to Microsoft SQL Server 2005 , point to Configuration Tools , and then click SQL Server Surface Area Configuration . Klik Start, menunjuk ke Program, jalur untuk Microsoft SQL Server 2005, menunjuk ke Konfigurasi Peralatan, dan kemudian klik SQL Server Permukaan Kawasan Konfigurasi.
2. On the SQL Server 2005 Surface Area Configuration page, click Surface Area Configuration for Services and Connections . Pada SQL Server 2005 Permukaan Kawasan Konfigurasi halaman, klik Permukaan Kawasan Konfigurasi untuk Layanan dan Sambungan.
3. On the Surface Area Configuration for Services and Connections page, expand Database Engine , click Remote Connections , click Local and remote connections , click the appropriate protocol to enable for your environment, and then click Apply . Pada permukaan Area Konfigurasi untuk Layanan dan Sambungan halaman, memperluas Database Engine, klik Remote Connections, klik lokal dan sambungan jarak jauh, klik yang sesuai protokol untuk memungkinkan Anda untuk lingkungan, dan kemudian klik Terapkan.

Note Click OK when you receive the following message: Catatan Klik OK bila Anda menerima pesan berikut:

Changes to Connection Settings will not take effect until you restart the Database Engine service. Perubahan untuk koneksi Pengaturan tidak akan berlaku sampai Anda restart Database Engine layanan.
4. On the Surface Area Configuration for Services and Connections page, expand Database Engine , click Service , click Stop , wait until the MSSQLSERVER service stops, and then click Start to restart the MSSQLSERVER service. Pada permukaan Area Konfigurasi untuk Layanan dan Sambungan halaman, memperluas Database Engine, klik Layanan, klik Berhenti, tunggu sampai MSSQLSERVER layanan akan berhenti, dan kemudian klik Start MSSQLSERVER untuk memulai kembali layanan.

Back to the top Kembali ke atas

Enable the SQL Server Browser service Aktifkan SQL Server Browser layanan

If you are running SQL Server 2005 by using an instance name and you are not using a specific TCP/IP port number in your connection string, you must enable the SQL Server Browser service to allow for remote connections. Jika anda menjalankan SQL Server 2005 dengan menggunakan sebuah contoh nama dan anda tidak menggunakan tertentu TCP / IP nomor port dalam string koneksi Anda, Anda harus mengaktifkan SQL Server Browser layanan untuk koneksi jauh. For example, SQL Server 2005 Express is installed with a default instance name of Computer Name \SQLEXPRESS. Misalnya, SQL Server 2005 Express terinstal dengan standar contoh nama Komputer Nama \ SQLEXPRESS. You are only required to enable the SQL Server Browser service one time, regardless of how many instances of SQL Server 2005 you are running. To enable the SQL Server Browser service, follow these steps. Anda hanya diminta untuk mengaktifkan SQL Server Browser layanan satu waktu, tanpa memperhitungkan jumlah contoh dari SQL Server 2005 anda berjalan. Untuk mengaktifkan layanan SQL Server Browser, ikuti langkah-langkah.

Important These steps may increase your security risk. Langkah-langkah penting Anda mungkin akan meningkatkan risiko keamanan. These steps may also make your computer or your network more vulnerable to attack by malicious users or by malicious software such as viruses. Langkah ini juga dapat membuat Anda komputer atau jaringan Anda lebih rentan terhadap serangan berbahaya oleh pengguna atau oleh virus seperti virus. We recommend the process that this article describes to enable programs to operate as they are designed to, or to implement specific program capabilities. Kami menyarankan proses artikel ini menjelaskan bahwa untuk mengaktifkan program untuk beroperasi seperti yang dirancang untuk, atau untuk melaksanakan program khusus kemampuan. Before you make these changes, we recommend that you evaluate the risks that are associated with implementing this process in your particular environment. Sebelum Anda membuat perubahan ini, kami menyarankan Anda mengevaluasi risiko yang berkaitan dengan penerapan proses ini dalam lingkungan tertentu. If you choose to implement this process, take any appropriate additional steps to help protect your system. Jika Anda memilih untuk melaksanakan proses ini, setiap mengambil langkah-langkah tambahan yang sesuai untuk membantu melindungi sistem anda. We recommend that you use this process only if you really require this process. Kami menyarankan Anda menggunakan proses ini hanya jika Anda benar-benar memerlukan proses ini.

1. Click Start , point to Programs , point to Microsoft SQL Server 2005 , point to Configuration Tools , and then click SQL Server Surface Area Configuration . Klik Start, menunjuk ke Program, jalur untuk Microsoft SQL Server 2005, menunjuk ke Konfigurasi Peralatan, dan kemudian klik SQL Server Permukaan Kawasan Konfigurasi.
2. On the SQL Server 2005 Surface Area Configuration page, click Surface Area Configuration for Services and Connections . Pada SQL Server 2005 Permukaan Kawasan Konfigurasi halaman, klik Permukaan Kawasan Konfigurasi untuk Layanan dan Sambungan.
3. On the Surface Area Configuration for Services and Connections page, click SQL Server Browser , click Automatic for Startup type , and then click Apply . Pada permukaan Area Konfigurasi untuk Layanan dan Sambungan halaman, klik SQL Server Browser, klik otomatis untuk jenis Startup, dan kemudian klik Terapkan.

Note When you click the Automatic option, the SQL Server Browser service starts automatically every time that you start Microsoft Windows. Catatan Bila anda klik pilihan otomatis, SQL Server Browser layanan dimulai secara otomatis setiap kali Anda memulai Microsoft Windows.

4. Click Start , and then click OK . Klik Start, dan kemudian klik OK.

Note When you run the SQL Server Browser service on a computer, the computer displays the instance names and the connection information for each instance of SQL Server that is running on the computer. Catatan Bila Anda menjalankan SQL Server Browser layanan pada sebuah komputer, komputer menampilkan contoh nama dan sambungan informasi untuk setiap contoh dari SQL Server yang berjalan pada komputer. This risk can be reduced by not enabling the SQL Server Browser service and by connecting to the instance of SQL Server directly through an assigned TCP port. Risiko ini dapat dikurangi dengan tidak memungkinkan SQL Server Browser dan layanan ini dengan terhubung ke instance dari SQL Server secara langsung melalui sebuah port TCP ditugaskan. Connecting directly to an instance of SQL Server through a TCP port is beyond the scope of this article. Terhubung langsung ke sebuah contoh dari SQL Server melalui TCP port tidak dijelaskan di dalam artikel ini. For more information about the SQL Server Browser server and connecting to an instance of SQL Server, see the following topics in SQL Server Books Online: Untuk informasi lebih lanjut tentang SQL Server Browser menyambung ke server dan contoh SQL Server, lihat topik berikut dalam SQL Server Books Online:

SQL Server Browser Service SQL server layanan browser
Connecting to the SQL Server Database Engine Menghubungkan ke server database SQL mesin
Client Network Configuration Klien konfigurasi jaringan

Back to the top Kembali ke atas

Create exceptions in Windows Firewall Buat pengecualian pada Windows Firewall

These steps apply to the version of Windows Firewall that is included in Windows XP Service Pack 2 (SP2) and in Windows Server 2003. Langkah-langkah ini berlaku untuk versi Windows Firewall yang disertakan dalam Windows XP Service Pack 2 (SP2) dan di Windows Server 2003. If you are using a different firewall system, see your firewall documentation for more information. Jika anda menggunakan sistem firewall yang berbeda, firewall anda lihat dokumentasi untuk informasi lebih lanjut.

If you are running a firewall on the computer that is running SQL Server 2005, external connections to SQL Server 2005 will be blocked unless SQL Server 2005 and the SQL Server Browser service can communicate through the firewall. Jika Anda menjalankan firewall pada komputer yang menjalankan SQL Server 2005, koneksi eksternal untuk SQL Server 2005 akan diblokir kecuali SQL Server 2005 dan SQL Server Browser layanan dapat berkomunikasi melalui firewall. You must create an exception for each instance of SQL Server 2005 that you want to accept remote connections and an exception for the SQL Server Browser service. Anda harus membuat pengecualian untuk setiap instance dari SQL Server 2005 yang akan menerima koneksi jauh dan pengecualian untuk SQL Server Browser layanan.

SQL Server 2005 uses an instance ID as part of the path when you install its program files. SQL Server 2005 menggunakan sebuah contoh ID sebagai bagian dari path bila Anda memasang program file. To create an exception for each instance of SQL Server, you must identify the correct instance ID. Untuk membuat pengecualian untuk setiap instance dari SQL Server, Anda harus mengidentifikasi contoh ID yang benar. To obtain an instance ID, follow these steps: Untuk mendapatkan contoh ID, ikuti langkah berikut:

1. Click Start , point to Programs , point to Microsoft SQL Server 2005 , point to Configuration Tools , and then click SQL Server Configuration Manager . Klik Start, menunjuk ke Program, jalur untuk Microsoft SQL Server 2005, menunjuk ke Konfigurasi Peralatan, dan kemudian klik SQL Server Konfigurasi Antara.
2. In SQL Server Configuration Manager, click the SQL Server Browser service in the right pane, right-click the instance name in the main window, and then click Properties . Dalam SQL Server Configuration Manager, klik SQL Server Browser layanan dalam pane kanan, klik kanan contoh nama di jendela utama, dan kemudian klik Properties.
3. On the SQL Server Browser Properties page, click the Advanced tab, locate the instance ID in the property list, and then click OK . Pada SQL Server Browser halaman Properties, klik tab Advanced, cari contoh ID dalam daftar properti, dan kemudian klik OK.

To open Windows Firewall, click Start , click Run , type firewall.cpl , and then click OK . Untuk membuka Windows Firewall, klik Start, klik Run, ketik firewall.cpl, dan kemudian klik OK.

Create an exception for SQL Server 2005 in Windows Firewall Buat kecuali untuk SQL Server 2005 di Windows Firewall

To create an exception for SQL Server 2005 in Windows Firewall, follow these steps: Untuk membuat pengecualian untuk SQL Server 2005 di Windows Firewall, ikuti langkah berikut:

1. In Windows Firewall, click the Exceptions tab, and then click Add Program . Dalam Windows Firewall, klik tab Exceptions, dan kemudian klik Add Program.
2. In the Add a Program window, click Browse . Dalam Tambahkan Program jendela, klik tombol Browse.
3. Click the C:\Program Files\Microsoft SQL Server\ MSSQL.1 \MSSQL\Binn\sqlservr.exe executable program, click Open , and then click OK . Klik C: \ Program Files \ Microsoft SQL Server \ MSSQL.1 \ MSSQL \ Binn \ sqlservr.exe program dijalankan, klik Open, dan kemudian klik OK.

Note The path may be different depending on where SQL Server 2005 is installed. MSSQL.1 is a placeholder for the instance ID that you obtained in step 3 of the previous procedure. Catatan Path mungkin berbeda tergantung di mana SQL Server 2005 adalah terpasang. MSSQL.1 merupakan tempat untuk contoh ID yang diperoleh di langkah 3 dari prosedur sebelumnya.

4. Repeat steps 1 through 3 for each instance of SQL Server 2005 that needs an exception. Ulangi langkah 1 sampai dengan 3 untuk setiap instance dari SQL Server 2005 yang memerlukan pengecualian.

Create an exception for the SQL Server Browser service in Windows Firewall Buat kecuali untuk SQL Server Browser layanan pada Windows Firewall

To create an exception for the SQL Server Browser service in Windows Firewall, follow these steps: Untuk membuat pengecualian untuk SQL Server Browser layanan pada Windows Firewall, ikuti langkah berikut:

1. In Windows Firewall, click the Exceptions tab, and then click Add Program . Dalam Windows Firewall, klik tab Exceptions, dan kemudian klik Add Program.
2. In the Add a Program window, click Browse . Dalam Tambahkan Program jendela, klik tombol Browse.
3. Click the C:\Program Files\Microsoft SQL Server\90\Shared\sqlbrowser.exe executable program, click Open , and then click OK . Klik C: \ Program Files \ Microsoft SQL Server \ 90 \ Shared \ sqlbrowser.exe program dijalankan, klik Open, dan kemudian klik OK.

Note The path may be different depending on where SQL Server 2005 is installed. Catatan Path mungkin berbeda tergantung di mana SQL Server 2005 adalah terpasang.

Posted in Database (SQL SERVER, MYSQL etc) | Leave a comment

Mengubah Font, PaperSize,Orientation pada crystal report

Menggunakan VB.net

Mungkin banyak teman-teman yang belum tau bagaiman mengubah papersize, font, Orientation pada crystal report lewat Vb.net

Imports CrystalDecisions.CrystalReports
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.CrystalReports.Engine.Section
Imports CrystalDecisions.CrystalReports.Engine.FieldObject
Imports CrystalDecisions.CrystalReports.Engine.TextObject
Imports CrystalDecisions.Shared

Public Class Cetakan
Private rpt As Engine.ReportDocument
Private sub Cetak

Public Structure CetakKePrinter
Public namaReport As String
Public namaDatabase As String
Public namaServerDb As String
Public namaUserId As String
Public namaPassw As String
End Structure
rpt=new Engine.ReportDokumen

Dim cr As CetakKePrinter
cr.namaDatabase = data_base
cr.namaPassw = passWord
cr.namaServerDb = sErver
cr.namaUserId = “sa”
cr.namaReport = App_Path() & “/” & Me.NamaLaporan & “.rpt”
rpt.Load(cr.namaReport, OpenReportMethod.OpenReportByDefault)

Dim header As Single = 215.9 – UkuranBuku.Text
Dim Top As Integer = CInt((1440 / 25.4 * header) + (1440 / 25.4 * tinggi.Text))
Dim Left As Integer = CInt(1440 / 25.4 * kiri.Text)

rpt.PrintOptions.PaperSize = PaperSize.PaperLegal
rpt.PrintOptions.PaperOrientation = PaperOrientation.Landscape
rpt.PrintOptions.ApplyPageMargins(New CrystalDecisions.Shared.PageMargins(Left, Top, 0, 0))

Dim Huruf As New Font(Me.TxtHuruf.Text, Me.txtukuranhuruf.Text)
‘pengubahan Section
Dim mySection As Section = rpt.ReportDefinition.Sections.Item(“Section3”)
Dim Teks As FieldObject
For i As Integer = 0 To MySection.ReportObject.Item.Count-1
Teks = mySection.ReportObjects.Item(i)
Teks.ApplyFont(Huruf)
Next
End Select
crp.ReportSource = rpt ‘ crp adalah Crystal Report Dokumen
crp.RefreshReport()

Posted in Pemerograman Visual Basic.net | 1 Comment