Hi all..
I hope someone here can help me to solve my problem...I try to serach and get the solution from google..but it not help much...
when I click button on page..the data will inserted twice in my database...
i using select and insert statement in same connection...
also have executeScalar() and executeNonQuery() at the same time...
i using executeScalaer for get the data from column..
and executeNon Query to insert into database..
i hope somebody willing to see my coding here...
Private Function TambahRekod(ByVal sNama As String, ByVal sAlmt1 As String, ByVal sAlmt2 As String, ByVal sAlmt3 As String, ByVal sPoskod As String, ByVal sBdr As String, ByVal sNgri As String, ByVal sNBank As String, ByVal sNoABnk As String, ByVal sAlmtBnk1 As String, ByVal sAlmtBnk2 As String, ByVal sAlmtBnk3 As String, ByVal sPoskodBnk As String, ByVal sBdrBnk As String, ByVal sNgriBnk As String) As String
Dim sSamb As String = ConfigurationManager.ConnectionStrings("cons_skew").ConnectionString
Dim odbcSamb As New OdbcConnection(sSamb)
Dim sQuery1 As String = "SELECT MAX(wc15kodplgn)FROM wc15fiplgnu WHERE (wc15kodplgn LIKE 'LP%')"
odbcSamb.Open()
Dim odbcArahan As New OdbcCommand(sQuery1, odbcSamb)
Dim skodplgn As String = odbcArahan.ExecuteScalar()
skodplgn = skodplgn.Substring(2)
Dim skodplgn3 As Int32 = Convert.ToInt32(skodplgn) + 1
Dim skodplgn2 As String = "LP" + skodplgn3.ToString()
lblTest1.Text = skodplgn2
Try
Dim sQuery As String = "INSERT INTO wc15fiplgnu (wc15kodplgn, wc15nama, wc15almt1, wc15almt2, wc15almt3, wc15poskod, wc15bandar, wc15negeri, wc15namabank, wc15noakbank, wc15albnk1, wc15albnk2, wc15albnk3, wc15pkdbnk, wc15bdrbnk, wc15ngrbnk) VALUES ('" + skodplgn2 + "','" + sNama + "','" + sAlmt1 + "','" + sAlmt2 + "','" + sAlmt3 + "','" + sPoskod + "','" + sBdr + "','" + sNgri + "','" + sNBank + "','" + sNoABnk + "','" + sAlmtBnk1 + "','" + sAlmtBnk2 + "','" + sAlmtBnk3 + "','" + sPoskodBnk + "','" + sBdrBnk + "','" + sNgriBnk + "')"
Dim odbcArah1 As New OdbcCommand(sQuery, odbcSamb)
odbcArah1.ExecuteNonQuery()
Catch ex As Exception
System.Diagnostics.Trace.WriteLine("[Pendaftaran Pembekal] Ralat " & ex.Message)
End Try
odbcSamb.Close()
Return True
End Function