Uwais Al-Qarani 0 Report post Posted April 24, 2008 Salamaku punya database dah bole masuk,sekarang nie aku nak update kan bilangan no nyer,mcm dari 0,pastu aku tekan buttton save,secara automatik Bil tu akan update ke 1 dari kosong dan seterusnyacontoh coding akuProtected Sub SimpanAduan() Dim Conn As OdbcConnection = New OdbcConnection(sDB) Conn.Open() Try Dim sCmd As OdbcCommand = New OdbcCommand sCmd.CommandText = "INSERT Into ad_AduanHdr VALUES('" + txtLabel.Text + "','" + txtNoKadPengenalan.Text + "','" + txtNama.Text + "','" + txtEmail.Text + "','" + _ txtNoTelefon.Text + "','" + txtNoHp.Text + "','" + txtAdd1.Text + "','" + txtAdd2.Text + "','" + txtPoskod.Text + "','" + _ txtBandar.Text + "','" + ddlNegeri.SelectedValue + "','" + ddlNegara.SelectedValue + "','" + txtTajuk.Text + "','" + txtAduan.Text + "','" + _ rbJenis.SelectedValue + "',getdate(),'" + ddlKategori.SelectedValue + "')" sCmd.Connection = Conn With sCmd .Parameters.Add(New OdbcParameter("@sNoID", txtNoKadPengenalan.Text)) .Parameters.Add(New OdbcParameter("@sNama", txtNama.Text)) End With sCmd.ExecuteNonQuery().ToString() Catch ex As OdbcException Response.Write("Proses tidak berjaya. Sila hubungi Pengurus Sistem dengan menyalin Ralat berikut : <BR>" + ex.ToString + sCmd) Finally Conn.Close() End Try End Subperlukah aku gunakan array? Quote Share this post Link to post Share on other sites
Uwais Al-Qarani 0 Report post Posted April 25, 2008 Function runNo(ByVal strID As String) Dim Conn As OdbcConnection = New OdbcConnection(sDB) Dim no As Integer Conn.Open() Dim sCmd As OdbcCommand = New OdbcCommand sCmd.CommandText = "SELECT iRunNo FROM ad_RunNo" 'If SimpanAduan(1, 1, False, , row) = False Then Exit Sub If SimpanAduan(1, 1, True, sCmd, row) Then no = myArray(0, 0) + 1 Else no = 1 End If Conn.Close() End Functionini untuk array,tapi error diaError 4 Too many arguments to 'Protected Sub SimpanAduan()'. c:\inetpub\wwwroot\AduanLatest\AduanHeader.aspx.vb 101 24 http://localhost/AduanLatest/so camner nak settle kan ar?pening nie Quote Share this post Link to post Share on other sites
DrASAG 0 Report post Posted April 25, 2008 A'kum.sub utk SimpanAduan tu, macam kat atas tu ker? dalam function runNo ko panggil sub SimpanAduan, hantar 5 nilai, tapi dlm sub SimpanAduan ko tak terima nilai tu.... Quote Share this post Link to post Share on other sites
Uwais Al-Qarani 0 Report post Posted April 25, 2008 Salam,yup SimpanAduan tu mcm dekat coding atas tu,mcmana nak buat?aku seriously x paham Quote Share this post Link to post Share on other sites
DrASAG 0 Report post Posted April 25, 2008 ko tgk function ni Function runNo(ByVal strID As String)kat situ ko terima satu nilai string kan. skang ni ko panggil sub simpanaduan, ko hantar nilai 1,1.... tu semua kan. tapi kat kepala sub simpanaduan tu, ko tak terima nilai... errr ko paham ker... hehehehe... Quote Share this post Link to post Share on other sites
Uwais Al-Qarani 0 Report post Posted April 25, 2008 xpaham...huaaa...ini aku jelaskan situasi akuada dua situasipertama :aku nak bila tekan radiobutton(list dlm radiobutton nie aku link dengan database) secara automatik nya iRunNo dalam rbutton nie akan naik sendiricontoh...aku tekan rbutton Belanjawan,dlam iRunNo,dari 0 akan update kepada 1 dan seterusnyaKedua :aku nak create auto doc ID,contoh bila aku clik submit,secara automatik dokumen id akan digenerate contoh : ad08-0001tolong kawan2 aku dah buntu nie,darah pun dah naik,dah ler aku ada darah tinggi150/90..tinggi tu @_@aku dah ler major networking sekali terjun dalam nie..huhu yg amik software engineering pun dah pening,tambah plak aku yg sikit babing ilmu programming nie..pening2..tekanan..ini ym aku [email protected]kalau2 ada yg sudi menolong,aku area penang,xkisah ler mana korang duduk aku akan pergi menuntut ilmu,huhuhu Quote Share this post Link to post Share on other sites
DrASAG 0 Report post Posted April 25, 2008 hehehehe... sian ko... huhuhuhu.. cek nak nolong pon tak pandai sangat. utk yg pertama tu aku tak paham. utk yg kedua tu, kalo nak wat auto id pakai autonumber la. hehehe... tak pon ko leh wat fungsi lain. contoh..Function tambahID(ByVal strsql As String) Dim str As String sConn.Open() Dim sCmd As New SqlCommand(strsql, sConn) Dim rdset As SqlDataReader = sCmd.ExecuteReader() If rdset.Read Then If rdset("IDnumber").ToString <> "" Then str = Format(Now, "yy") & "-" & Format(Val(Right(rdset("IDnumber"), 3) + 1), "0##") Else str = Format(Now, "yy") & "-" & Format(1, "0##") End If End If rdset.Close() sConn.Close() Return str End Function so, untuk wat auto ID ni, ko kena panggil fungsi kat atas contohnya camni.. sSql = "SELECT MAX(IDnumber)AS ID FROM tblengkau" strID = tambahID(sSql)so bila ko panggil fungsi tambahID tu, dia akan cari nilai ID yang paling besar dlm table ko, then dia akan generate ID baru. kalo ko tgk fungsi kat atas tu, dia akan generate IDnumber=08-001 pastu 08-002 dan seterusnya ler... so kalo ko nak wat ko punya format pon bleh, ubah ler kat str=.............. tu....hehehehe.. Quote Share this post Link to post Share on other sites
Uwais Al-Qarani 0 Report post Posted April 25, 2008 (edited) terima kasih brader,nanti aku jumpa devguy,aku nak jumpa ko skali,xper aku try dulu coding nie..thx sgt2 bro Else SimpanAduan() Dim MyScript As String = "<script language='javascript'>window.alert('Data Telah Di simpan.')</SCRIPT>" ClientScript.RegisterStartupScript(Me.GetType(), "ErrSave", MyScript) tambahID(lblDok.Text) Dim MyScript As String = "<script language='javascript'>window.alert('Data Telah Di simpan.')</SCRIPT>" ClientScript.RegisterStartupScript(Me.GetType(), "ErrSave", MyScript) ClearData() End If Function tambahID(ByVal strsql As String) Dim str As String Dim Conn As OdbcConnection = New OdbcConnection(sDB) Conn.Open() Dim sCmd As New OdbcCommand(strsql, Conn) Dim rdset As OdbcDataReader = sCmd.ExecuteReader() If rdset.Read Then If rdset("IDnumber").ToString <> "" Then str = Format(Now, "yy") & "-" & Format(Val(Right(rdset("IDnumber"), 3) + 1), "0##") Else str = Format(Now, "yy") & "-" & Format(1, "0##") End If End If rdset.Close() Conn.Close() Return str End Function yg atas nie aku dah edit,cuma dekat str tubawah dia ada kaler line kaler hijau,asal? ini aku dah panggil function tu cuma aku xpaham sSql = "SELECT MAX(IDnumber)AS ID FROM tblengkau" strID = tambahID(sSql)kena letak kat mana?ada ym x DrAsag? Edited April 25, 2008 by Divine Divinitys X Quote Share this post Link to post Share on other sites
DrASAG 0 Report post Posted April 25, 2008 hohohoho... bereh jer. ko penang kat USM ka? PTM kat situ ker? huhuhuhuhu.... Quote Share this post Link to post Share on other sites
Uwais Al-Qarani 0 Report post Posted April 25, 2008 apa tu PTM?aku kat USM jabatan bendaharisoalan aku kat atas tu camner nak selesaikan?ada ym x? Quote Share this post Link to post Share on other sites
DrASAG 0 Report post Posted April 25, 2008 kaler hijo? hehehehe.. sbb dia return value nilai dia takder lagik .. rasanya la... abaikan jer yg tu. hehehehe... warning jer kot. PTM? peg tek maklumat... ko nak tambah id tu utk yg mana? cth kalo ko nk register new item, then ko nak id dia auto increment dlm format cam kat atas tu... ko panggil fungsi tu sebelum ko save new item tu... YM? ada, tapi aku jarang guna... Quote Share this post Link to post Share on other sites
Uwais Al-Qarani 0 Report post Posted April 28, 2008 salam!bermula la pagi yg xbeberapa indah,huhusSql = "SELECT MAX(IDnumber)AS ID FROM tblengkau"strID = tambahID(sSql)di mana aku nak letak declaration ini Quote Share this post Link to post Share on other sites
DrASAG 0 Report post Posted April 28, 2008 aku dah emel kat ko...hehehehehe Quote Share this post Link to post Share on other sites
Uwais Al-Qarani 0 Report post Posted April 28, 2008 thx bro,ko mmg cepat!keja mana?leh ngeteh nanti Quote Share this post Link to post Share on other sites
DrASAG 0 Report post Posted April 28, 2008 huhhuhuhu.... dah dpt ka? boleh ka? Quote Share this post Link to post Share on other sites
Uwais Al-Qarani 0 Report post Posted April 28, 2008 Salambro,coding yg ko guna untuk dummy db yg ko email kat aku tu,still coding yg sama ker?aku x beberapa expert untuk memanggil function coding tu ini contoh coding aku,harap sapa2 dapat tolong,hanya Allah yg dapat balas, Else SimpanAduan() Dim MyScript As String = "<script language='javascript'>window.alert('Data Telah Di simpan.')</SCRIPT>" ClientScript.RegisterStartupScript(Me.GetType(), "ErrSave", MyScript) If btnHantar.OnClientClick = "Simpan Data" Then sCmd = "SELECT MAX(IDnumber)AS ID FROM ad_AduanHdr" str = tambahID(sCmd) MyScript = "<script language='javascript'>window.alert('Data Telah Di simpan.')</SCRIPT>" ClientScript.RegisterStartupScript(Me.GetType(), "ErrSave", MyScript) ClearData() Else Exit Sub ini coding yg aku guna untuk panggil function tambahID,ada kesilapan berlaku,tapi aku x taw dekat mana Function tambahID(ByVal strodbc As String) Dim Conn As OdbcConnection = New OdbcConnection(sDB) Conn.Open() Dim sCmd As New OdbcCommand(strodbc, Conn) Dim rdset As OdbcDataReader = sCmd.ExecuteReader() If rdset.Read Then If rdset("IDnumber").ToString <> "" Then str = Format(Now, "yy") & "-" & Format(Val(Right(rdset("IDnumber"), 3) + 1), "0##") Else str = Format(Now, "yy") & "-" & Format(1, "0##") End If End If rdset.Close() Conn.Close() Return str End Function ini pula function tambahID yg aku amik dari atas tu,cuma aku x pasti kat mana nak letak ini sSql = "SELECT MAX(IDnumber)AS ID FROM tblengkau" strID = tambahID(sSql) Quote Share this post Link to post Share on other sites
Uwais Al-Qarani 0 Report post Posted April 28, 2008 sIdAduan Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IndexOutOfRangeException: sIdAduanSource Error: Line 106:Line 107: If rdset.Read ThenLine 108: If rdset("sIdAduan").ToString <> "" ThenLine 109: str = Format(Now, "yy") & "-" & Format(Val(Right(rdset("sIdAduan"), 3) + 1), "0##")Line 110: Else huhu kuar error kat sini XD,penat mencari Quote Share this post Link to post Share on other sites
Uwais Al-Qarani 0 Report post Posted April 28, 2008 DrAsag,mana ko..huhu gue perlukan pertolongan nie Quote Share this post Link to post Share on other sites
DrASAG 0 Report post Posted April 28, 2008 A'kum... ehehehehe sabor2, aku baru abih miting laa.... hahahahaha... akuk dah email ko.. Quote Share this post Link to post Share on other sites
Uwais Al-Qarani 0 Report post Posted April 28, 2008 aku paham ko nyer coding tu mmmg membina ummah,aiseh..kekek tapi,aku x reti nak letak kat mana,itu jer,weh,ko leh ajar aku x?aku turun kl ok?aku belanja ler apa2 ker Quote Share this post Link to post Share on other sites
DrASAG 0 Report post Posted April 28, 2008 A'kum... hehehehehe... error apa skang? kat yg hang bold tu ker? hehehehe aku wat ok jer... pakai sybase ker? aku tak penah guna benda alah tu.. hehehehe.. ko wat dummy program guna acces ada masalah ke tak? kalo takder masalah, mmg takder masalah la. hehehehe... maybe kena tukar sket implementasi kod ko... Quote Share this post Link to post Share on other sites
Uwais Al-Qarani 0 Report post Posted April 28, 2008 If rdset("sIdAduan").ToString <> "" Then str = Format(Now, "yy") & "-" & Format(Val(Right(rdset("sIdAduan"), 3) + 1), "0##") Elseerror dia kat sini kat "If rdset("sIdAduan").ToString <> "" Then"naper ek???pening sgt2 dah nie,huhuhu,aku x taw nak letak natang nie kat manasSql = "SELECT MAX(IDnumber)AS ID FROM tblengkau"strID = tambahID(sSql) Quote Share this post Link to post Share on other sites
DrASAG 0 Report post Posted April 28, 2008 uik kan dah cakap letak sebelum ko panggil fungsi simpanaduan() tu. kalo dah ubah, kira betul la tu. yg problem skang yg hang ckp tu, bukan masalah tatau nk letak panggilan fungsi tu kat mana.. skang ni table ko kosong lagik kan? cuba ko ubah kod utk fungsi tambahID tu.. Dim sCmd As New OdbcCommand(strodbc, Conn) Dim rdset As OdbcDataReader = sCmd.ExecuteReader() if rdset.Hasrows Then rdset.Read If rdset("IDnumber").ToString <> "" Then str = Format(Now, "yy") & "-" & Format(Val(Right(rdset("IDnumber"), 3) + 1), "0##") Else str = Format(Now, "yy") & "-" & Format(1, "0##") End If End Iftakpun ko tukar If rdset("IDnumber").ToString <> "" Then tu jadik If rdset("IDnumber") <> DBNull.Value Then Quote Share this post Link to post Share on other sites
Uwais Al-Qarani 0 Report post Posted April 29, 2008 camana aku nak letakkan supaya id dokumen itu masuk ke dlm label atau text box?aku xreti programming nie tapi terpaksa juga buat even bukan dalam bidang akutgh struggle,thx for the help Quote Share this post Link to post Share on other sites
DrASAG 0 Report post Posted April 29, 2008 A'kum...TextBox1.Text = strID@Label1.Text = strID Quote Share this post Link to post Share on other sites