how to save data using service based database.?
-
jeudi 2 août 2012 19:04
i just started using Service-Based Database function.
but i facing some issue. data lost when i check it (open data table).
this is my coding, i not confident with servicebased i always using access. but i like to try new thing. do you guys have solution or other method that i can use.? please help.
Public Class Area Dim sept_um, tr_um, lcd_um, cds_um, sbtr_um, fdt_um, e_um, ttl_um As String Dim sept_r, tr_r, lcd_r, cds_r, sbtr_r, fdt_r, e_r, ttl_r As String Dim sept_ag, tr_ag, lcd_ag, cds_ag, sbtr_ag, fdt_ag, e_ag, ttl_ag As String Dim sept_com, tr_com, lcd_com, cds_com, sbtr_com, fdt_com, e_com, ttl_com As String Dim sept_rc, tr_rc, lcd_rc, cds_rc, sbtr_rc, fdt_rc, e_rc, ttl_rc As String Dim ttl_sept, ttl_tr, ttl_lcd, ttl_cds, ttl_sbtr, ttl_fdt, ttl_e, ttl_ttl As String Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 'this is the coding to save it, i saw this in youtube If AreaTableAdapter1.CheckSerial_No(TextBox1.Text) = Nothing Then AreaTableAdapter1.InsertQuery(TextBox1.Text, txtsept_um.Text, txtsept_r.Text, txtsept_ag.Text, txtsept_com.Text, txtsept_rc.Text, txtttl_sept.Text, txtcds_um.Text, txtcds_r.Text, txtcds_ag.Text, txtcds_com.Text, txtcds_rc.Text, txtttl_cds.Text, txttr_um.Text, txttr_r.Text, txttr_ag.Text, txttr_com.Text, txttr_rc.Text, txtttl_tr.Text, txtsbtr_um.Text, txtsbtr_r.Text, txtsbtr_ag.Text, txtsbtr_com.Text, txtsbtr_rc.Text, txtttl_sbtr.Text, txtlcd_um.Text, txtlcd_r.Text, txtlcd_ag.Text, txtlcd_com.Text, txtlcd_rc.Text, txtttl_lcd.Text, txtfdt_um.Text, txtfdt_r.Text, txtfdt_ag.Text, txtfdt_com.Text, txtfdt_rc.Text, txtttl_fdt.Text, txte_um.Text, txte_r.Text, txte_ag.Text, txte_com.Text, txte_rc.Text, txtttl_e.Text, txtttl_um.Text, txtttl_r.Text, txtttl_ag.Text, txtttl_com.Text, txtttl_rc.Text, txtttl_ttl.Text) MsgBox("Succesfully Save Data To Database", MsgBoxStyle.Information) Else MsgBox("Serial Number Already Exist in Databse") End If Cost.MdiParent = home Cost.Show() Me.Hide() End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Close() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim sept_um, tr_um, lcd_um, cds_um, sbtr_um, fdt_um, e_um As Double Dim sept_r, tr_r, lcd_r, cds_r, sbtr_r, fdt_r, e_r As Double Dim sept_ag, tr_ag, lcd_ag, cds_ag, sbtr_ag, fdt_ag, e_ag As Double Dim sept_com, tr_com, lcd_com, cds_com, sbtr_com, fdt_com, e_com As Double Dim sept_rc, tr_rc, lcd_rc, cds_rc, sbtr_rc, fdt_rc, e_rc As Integer sept_um = CDbl(txtsept_um.Text) tr_um = CDbl(txttr_um.Text) cds_um = CDbl(txtcds_um.Text) lcd_um = CDbl(txtlcd_um.Text) sbtr_um = CDbl(txtsbtr_um.Text) fdt_um = CDbl(txtfdt_um.Text) e_um = CDbl(txte_um.Text) sept_r = CDbl(txtsept_r.Text) tr_r = CDbl(txttr_r.Text) cds_r = CDbl(txtcds_r.Text) lcd_r = CDbl(txtlcd_r.Text) sbtr_r = CDbl(txtsbtr_r.Text) fdt_r = CDbl(txtfdt_r.Text) e_r = CDbl(txte_r.Text) sept_ag = CDbl(txtsept_ag.Text) tr_ag = CDbl(txttr_ag.Text) cds_ag = CDbl(txtcds_ag.Text) lcd_ag = CDbl(txtlcd_ag.Text) sbtr_ag = CDbl(txtsbtr_ag.Text) fdt_ag = CDbl(txtfdt_ag.Text) e_ag = CDbl(txte_ag.Text) sept_com = CDbl(txtsept_com.Text) tr_com = CDbl(txttr_com.Text) cds_com = CDbl(txtcds_com.Text) lcd_com = CDbl(txtlcd_com.Text) sbtr_com = CDbl(txtsbtr_com.Text) fdt_com = CDbl(txtfdt_com.Text) e_com = CDbl(txte_com.Text) sept_rc = CDbl(txtsept_rc.Text) tr_rc = CDbl(txttr_rc.Text) cds_rc = CDbl(txtcds_rc.Text) lcd_rc = CDbl(txtlcd_rc.Text) sbtr_rc = CDbl(txtsbtr_rc.Text) fdt_rc = CDbl(txtfdt_rc.Text) e_rc = CDbl(txte_rc.Text) Dim totalsept, totaltr, totallcd, totalcds, totalsbtr, totalfdt, totale, totalttl As Double Dim totalum, totalr, totalag, totalcom, totalrc As Double totalsept = sept_um + sept_r + sept_ag + sept_com + sept_rc totaltr = tr_um + tr_r + tr_ag + tr_com + tr_rc totallcd = lcd_um + lcd_r + lcd_ag + lcd_com + lcd_rc totalcds = cds_um + cds_r + cds_ag + cds_com + cds_rc totalsbtr = sbtr_um + sbtr_r + sbtr_ag + sbtr_com + sbtr_rc totalfdt = fdt_um + fdt_r + fdt_ag + fdt_com + fdt_rc totale = e_um + e_r + e_ag + e_com + e_rc txtttl_sept.Text = totalsept txtttl_tr.Text = totaltr txtttl_lcd.Text = totallcd txtttl_cds.Text = totalcds txtttl_sbtr.Text = totalsbtr txtttl_fdt.Text = totalfdt txtttl_e.Text = totale totalum = sept_um + tr_um + cds_um + lcd_um + sbtr_um + fdt_um + e_um totalr = sept_r + tr_r + cds_r + lcd_r + sbtr_r + fdt_r + e_r totalag = sept_ag + tr_ag + cds_ag + lcd_ag + sbtr_ag + fdt_ag + e_ag totalcom = sept_com + tr_com + cds_com + lcd_com + sbtr_com + fdt_com + e_com totalrc = sept_rc + tr_rc + cds_rc + lcd_rc + sbtr_rc + fdt_rc + e_rc txtttl_um.Text = totalum txtttl_r.Text = totalr txtttl_ag.Text = totalag txtttl_com.Text = totalcom txtttl_rc.Text = totalrc totalttl = totalum + totalr + totalag + totalcom + totalrc + totalsept + totaltr + totallcd + totalcds + totalsbtr + totalfdt + totale txtttl_ttl.Text = totalttl End Sub End Class
S.S
- Modifié Syahman jeudi 2 août 2012 19:05
Toutes les réponses
-
jeudi 2 août 2012 22:13
Can you explain to us what a service based database is?
Wikepedia does not return any answer so probably you use a wrong description.
http://en.wikipedia.org/w/index.php?search=service+based+database&button=&title=Special%3ASearch
Success
Cor -
vendredi 3 août 2012 01:32
Hmmm...How do i explain it...
actually it form the add new item...
add new item then i click data, and there will be a service-based database.
i follow the tutor in youtube then im lost.
and the discription that i saw for it is an empty SQL Server database for service-based database that the discription.
S.S
-
lundi 6 août 2012 03:38Modérateur
Hi Syahman,
Could you please provide codes of InsertQuery method? Moreover, please take a look at this article about:Insert & Retrieve from Service Based Database http://goo.gl/wI5r6
Hope that helps.
Best regards,
Shanks Zen
MSDN Community Support | Feedback to us
- Modifié Shanks ZenMicrosoft Contingent Staff, Moderator lundi 20 août 2012 06:06 link not available now, change to cache page
-
lundi 6 août 2012 04:05
Hi shanks Zen,
this is the coding for InsertQuery :
INSERT INTO AREA (Serial_No, SEPT_UM, SEPT_RES, SEPT_AGRI, SEPT_COMMER, SEPT_RESCOM, SEPT_TOTA, CDS_UM, CDS_RES, CDS_AGRI, CDS_COMMER, CDS_RESCOM, CDS_TOTA, TR_UM, TR_RES, TR_AGRI, TR_COMMER, TR_RESCOM, TR_TOTA, SBTR_UM, SBTR_RES, SBTR_AGRI, SBTR_COMMER, SBTR_RESCOM, SBTR_TOTA, LCD_UM, LCD_RES, LCD_AGRI, LCD_COMMER, LCD_RESCOM, LCD_TOTA, FDT_UM, FDT_RES, FDT_AGRI, FDT_COMMER, FDT_RESCOM, FDT_TOTA, ECO_UM, ECO_RES, ECO_AGRI, ECO_COMMER, ECO_RESCOM, ECO_TOTA, TOTA_UM, TOTA_RES, TOTA_AGRI, TOTA_COMMER, TOTA_RESCOM, TOTA_TOTA) VALUES (@Serial_No,@SEPT_UM,@SEPT_RES,@SEPT_AGRI,@SEPT_COMMER,@SEPT_RESCOM,@SEPT_TOTA,@CDS_UM,@CDS_RES,@CDS_AGRI,@CDS_COMMER,@CDS_RESCOM,@CDS_TOTA,@TR_UM,@TR_RES,@TR_AGRI,@TR_COMMER,@TR_RESCOM,@TR_TOTA,@SBTR_UM,@SBTR_RES,@SBTR_AGRI,@SBTR_COMMER,@SBTR_RESCOM,@SBTR_TOTA,@LCD_UM,@LCD_RES,@LCD_AGRI,@LCD_COMMER,@LCD_RESCOM,@LCD_TOTA,@FDT_UM,@FDT_RES,@FDT_AGRI,@FDT_COMMER,@FDT_RESCOM,@FDT_TOTA,@ECO_UM,@ECO_RES,@ECO_AGRI,@ECO_COMMER,@ECO_RESCOM,@ECO_TOTA,@TOTA_UM,@TOTA_RES,@TOTA_AGRI,@TOTA_COMMER,@TOTA_RESCOM,@TOTA_TOTA)using this code
If AreaTableAdapter1.CheckSerial_No(TextBox1.Text) = Nothing Then AreaTableAdapter1.InsertQuery(TextBox1.Text, txtsept_um.Text, txtsept_r.Text, txtsept_ag.Text, txtsept_com.Text, txtsept_rc.Text, txtttl_sept.Text, txtcds_um.Text, txtcds_r.Text, txtcds_ag.Text, txtcds_com.Text, txtcds_rc.Text, txtttl_cds.Text, txttr_um.Text, txttr_r.Text, txttr_ag.Text, txttr_com.Text, txttr_rc.Text, txtttl_tr.Text, txtsbtr_um.Text, txtsbtr_r.Text, txtsbtr_ag.Text, txtsbtr_com.Text, txtsbtr_rc.Text, txtttl_sbtr.Text, txtlcd_um.Text, txtlcd_r.Text, txtlcd_ag.Text, txtlcd_com.Text, txtlcd_rc.Text, txtttl_lcd.Text, txtfdt_um.Text, txtfdt_r.Text, txtfdt_ag.Text, txtfdt_com.Text, txtfdt_rc.Text, txtttl_fdt.Text, txte_um.Text, txte_r.Text, txte_ag.Text, txte_com.Text, txte_rc.Text, txtttl_e.Text, txtttl_um.Text, txtttl_r.Text, txtttl_ag.Text, txtttl_com.Text, txtttl_rc.Text, txtttl_ttl.Text) MsgBox("Succesfully Save Data To Database", MsgBoxStyle.Information) Else MsgBox("Serial Number Already Exist in Databse") End If Cost.MdiParent = home Cost.Show() Me.Hide()
i able to save all the data when it i click NEXT button.
but when i close all my vb program and reopen it, the data not there anymore,
i changed "Copy to Output Directory" to copy if newer.
but still the data will reset to default.
S.S
-
lundi 20 août 2012 06:16Modérateur
Sorry for my late reply. I suppose you need to execute that command as is shown in my previous reply.
Best regards,
Shanks Zen
MSDN Community Support | Feedback to us
-
dimanche 9 septembre 2012 07:50
got it.
sorry for very late reply.
solve it by using this.
Dim serial_no As String serial_no = txtserial_no.Text If txtserial_no.Text = Nothing Then MsgBox("Please Press Button Create to Generate Serial Number", MsgBoxStyle.Information) Else If NEW_RECORDTableAdapter.CHECKSERIALQuery(txtserial_no.Text) = Nothing Then NEW_RECORDTableAdapter.InsertQuery(txtserial_no.Text, txtlocation.Text, ComboBox1.Text, DateTimePicker1.Text, TextBox3.Text, ComboBox2.Text, TextBox5.Text) MsgBox("Succesfully Save Data To Database", MsgBoxStyle.Information) Area_admin.Show() Me.Hide() Else MsgBox("Serial Number Already Exist in Database") End If End If
S.S
- Proposé comme réponse Frank L. SmithMicrosoft Community Contributor dimanche 9 septembre 2012 13:15
- Marqué comme réponse Shanks ZenMicrosoft Contingent Staff, Moderator lundi 10 septembre 2012 06:21

