Imports System.Data Imports System.Data.SqlClient Public Class Coba Dim con As SqlConnection Dim cmd As SqlCommand Dim reader As SqlDataReader Dim constring As String Dim SqlString As String Dim myConnection As SqlConnection Dim myCommand As SqlCommand Dim ra As Integer Private Sub Coba_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the '_FKIP_UNILAKDataSet.Ruangan' table. You can move, or remove it, as needed. Me.RuanganTableAdapter.Fill(Me._FKIP_UNILAKDataSet.Ruangan) constring = "Data Source=RAGAZ-PC\SQLEXPRESS;Initial Catalog=FKIP-UNILAK;Integrated Security=True" con = New SqlConnection(constring) con.Open() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim con As New SqlClient.SqlConnection Dim strCon As String = "Data Source=RAGAZ-PC\SQLEXPRESS;Initial Catalog=FKIP-UNILAK;Integrated Security=True" Dim strCommand As String = ("Insert into dbo.Ruangan (Id_Ruangan,Nama_Ruangan,Jenis_Ruangan) values (‘" & Me.id.Text & "’,‘" & Me.nama.Text & "’,‘" & Me.jenis.Text & "’)") Try con.ConnectionString = strCon Dim cm As New SqlClient.SqlCommand(strCommand, con) con.Open() cm.ExecuteNonQuery() MsgBox("Succesfully saved…") Catch ex As Exception MessageBox.Show(ex.Message, "Error") Finally If con.State = ConnectionState.Open Then con.Close() End If End Try End Sub End Class
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)