BUTTON SAVE
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
get_kon()
Dim simpan As SqlClient.SqlTransaction = kon.BeginTransaction
Dim command As SqlClient.SqlCommand = kon.CreateCommand
bersih()
Try
With command
.CommandText = "InputAnalis5C"
.CommandType = CommandType.StoredProcedure
.Connection = kon
.Transaction = simpan
.Parameters.Add("@NONAS", SqlDbType.NVarChar, 12).Value = TextBox1.Text
.Parameters.Add("@NAMA", SqlDbType.NVarChar, 75).Value = TextBox2.Text
.Parameters.Add("@ALAMAT", SqlDbType.NVarChar, 75).Value = TextBox3.Text
.Parameters.Add("@NOKTP", SqlDbType.NVarChar, 25).Value = TextBox4.Text
.Parameters.Add("@CHAR1", SqlDbType.NVarChar, 20).Value = TextBox5.Text
.Parameters.Add("@CHAR2", SqlDbType.NVarChar, 20).Value = TextBox6.Text
.Parameters.Add("@CHAR3", SqlDbType.NVarChar, 20).Value = TextBox7.Text
.Parameters.Add("@CHAR4", SqlDbType.NVarChar, 20).Value = TextBox8.Text
.Parameters.Add("@CHAR5", SqlDbType.NVarChar, 20).Value = TextBox9.Text
.Parameters.Add("@CHAR6", SqlDbType.NVarChar, 20).Value = TextBox10.Text
.Parameters.Add("@CHAR7", SqlDbType.NVarChar, 20).Value = TextBox11.Text
.Parameters.Add("@CHAR8", SqlDbType.NVarChar, 20).Value = TextBox12.Text
.Parameters.Add("@CHAR9", SqlDbType.NVarChar, 20).Value = TextBox13.Text
.Parameters.Add("@CHAR10", SqlDbType.NVarChar, 20).Value = TextBox14.Text
.Parameters.Add("@CHAR11", SqlDbType.NVarChar, 20).Value = TextBox15.Text
.Parameters.Add("@CHAR12", SqlDbType.NVarChar, 20).Value = TextBox16.Text
.Parameters.Add("@CAP1", SqlDbType.NVarChar, 20).Value = TextBox17.Text
.Parameters.Add("@CAP2", SqlDbType.NVarChar, 20).Value = TextBox18.Text
.Parameters.Add("@CAP3", SqlDbType.NVarChar, 20).Value = TextBox19.Text
.Parameters.Add("@CAP4", SqlDbType.NVarChar, 20).Value = TextBox20.Text
.Parameters.Add("@CAP5", SqlDbType.NVarChar, 20).Value = TextBox21.Text
.Parameters.Add("@CAP6", SqlDbType.NVarChar, 20).Value = TextBox22.Text
.Parameters.Add("@CAP7", SqlDbType.NVarChar, 20).Value = TextBox23.Text
.Parameters.Add("@CAP8", SqlDbType.NVarChar, 20).Value = TextBox24.Text
.Parameters.Add("@CAP9", SqlDbType.NVarChar, 20).Value = TextBox25.Text
.Parameters.Add("@CAP10", SqlDbType.NVarChar, 20).Value = TextBox26.Text
.Parameters.Add("@CAP11", SqlDbType.NVarChar, 20).Value = TextBox27.Text
.Parameters.Add("@CAP12", SqlDbType.NVarChar, 20).Value = TextBox28.Text
.Parameters.Add("@CAP13", SqlDbType.NVarChar, 20).Value = TextBox29.Text
.Parameters.Add("@CAP14", SqlDbType.NVarChar, 20).Value = TextBox30.Text
.Parameters.Add("@MOD1", SqlDbType.NVarChar, 20).Value = ComboBox1.Text
.Parameters.Add("@MOD2", SqlDbType.NVarChar, 20).Value = ComboBox2.Text
.Parameters.Add("@MOD3", SqlDbType.NVarChar, 20).Value = TextBox30.Text
.Parameters.Add("@CON1", SqlDbType.NVarChar, 20).Value = TextBox31.Text
.Parameters.Add("@CON2", SqlDbType.NVarChar, 20).Value = TextBox32.Text
.Parameters.Add("@CON3", SqlDbType.NVarChar, 20).Value = TextBox33.Text
.Parameters.Add("@CON4", SqlDbType.NVarChar, 20).Value = TextBox34.Text
.Parameters.Add("@COLL1", SqlDbType.NVarChar, 20).Value = CheckBox1
.Parameters.Add("@COLL2", SqlDbType.NVarChar, 20).Value = CheckBox2
.Parameters.Add("@COLL3", SqlDbType.NVarChar, 20).Value = CheckBox3
.Parameters.Add("@COLL4", SqlDbType.NVarChar, 20).Value = CheckBox4
.Parameters.Add("@COLL5", SqlDbType.NVarChar, 20).Value = CheckBox5
.Parameters.Add("@COLL1", SqlDbType.NVarChar, 20).Value = CheckBox6
.Parameters.Add("@COLL2", SqlDbType.NVarChar, 20).Value = CheckBox7
.Parameters.Add("@COLL3", SqlDbType.NVarChar, 20).Value = CheckBox8
.Parameters.Add("@COLL4", SqlDbType.NVarChar, 20).Value = CheckBox9
.Parameters.Add("@COLL5", SqlDbType.NVarChar, 20).Value = CheckBox10
.Parameters.Add("@HASIL1", SqlDbType.NVarChar, 20).Value = CheckBox13
.Parameters.Add("@HASIL2", SqlDbType.NVarChar, 20).Value = CheckBox14
.Parameters.Add("@HASIL3", SqlDbType.NVarChar, 20).Value = CheckBox15
.Parameters.Add("@HASIL4", SqlDbType.NVarChar, 20).Value = CheckBox16
.Parameters.Add("@HASIL1", SqlDbType.NVarChar, 20).Value = CheckBox17
.Parameters.Add("@HASIL2", SqlDbType.NVarChar, 20).Value = CheckBox18
.Parameters.Add("@HASIL3", SqlDbType.NVarChar, 20).Value = CheckBox19
.Parameters.Add("@HASIL4", SqlDbType.NVarChar, 20).Value = CheckBox20
.ExecuteNonQuery()
End With
simpan.Commit()
MsgBox("Data Berhasil di Simpan")
bersih()
Catch ex As Exception
MsgBox("Gagal tersimpan", MsgBoxStyle.Critical, "PERINGATAN")
End Try
End Sub
MY MODULE
Imports System.Data.Sql
Imports System.Data.SqlClient
Module koneksi
Public kon As SqlConnection
Public cmd As SqlCommand
Public da As SqlDataAdapter
Public dr As SqlDataReader
Public dt As DataTable
Public data As DataSet
Public myRow As DataRow
Public Sub get_kon()
Dim server As String
server = "Data Source=**************;Initial Catalog=CobaDbInput;User ID=sa;Password=***********"
kon = New SqlConnection(server)
Try
If kon.State = ConnectionState.Closed Then
kon.Open()
End If
Catch ex As Exception
MsgBox(Err.Description, MsgBoxStyle.Critical, "ERROR")
End Try
End Sub
End Module