Imports System.Data Imports System.Data.SqlClient Public Class LoopingDB 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 Da As SqlDataAdapter Dim Ds As DataSet Dim ra As Integer Dim myDA As New SqlDataAdapter Dim MyDS As New _FKIP_UNILAKDataSet() Dim numAffected As Integer Private Sub LagiiBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LagiiBindingNavigatorSaveItem.Click Me.Validate() Me.coordinateBindingSource.EndEdit() Me.coordinateTableAdapter.Update(Me._FKIP_UNILAKDataSet.coordinate) End Sub Private Sub LoopingDB_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.lagii' table. You can move, or remove it, as needed. Me.LagiiTableAdapter.Fill(Me._FKIP_UNILAKDataSet.lagii) constring = "Data Source=RAGAZ-PC\SQLEXPRESS;Initial Catalog=FKIP-UNILAK;Integrated Security=True" con = New SqlConnection(constring) con.Open() Da.Fill(Ds, "coordinate") End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i, j As Integer For i = 1 To 3 For j = 1 To 2 SqlString = "Insert coordinate values ('" (i) " ','" (j) "')" ' Here the problem cmd = New SqlCommand(SqlString, con) numAffected = cmd.ExecuteNonQuery Next Next MessageBox.Show("Data coordinate saved", "SUKSES", MessageBoxButtons.OK, MessageBoxIcon.Information) Me.coordinateTableAdapter.Fill(Me._FKIP_UNILAKDataSet.lagii) End Sub End Class
X_Value Y_Value<br /> 1 1<br /> 1 2<br /> 2 1<br /> 2 2<br /> 3 1 <br /> 3 2
insert into
SqlParameter
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)