Page 4 of 7 FirstFirst ... 23456 ... LastLast
Results 31 to 40 of 69
  1. #31

    Default

    what cbo gamiton? uns on mani kung mag insert na or update mostly dinhi bya mo dala trigger sa error

  2. #32

    Default

    post the code,suwayan nato kung masulbad ba. unya post sad ang data type sa imong tables.

  3. #33

    Default

    Quote Originally Posted by skeptic_rob View Post
    Private Sub cmdsave_Click()
    Dim rs As New ADODB.Recordset
    Dim sqlstr As String

    rs.Open sqlstr, Conn, adOpenDynamic, adLockOptimistic

    sqlstr = " insert into user_act(id,password,uname,date) values ('"&txtid.text&"','"&txtpassword.text"','"&txtunam e.text&"','#"&txtdate.text&"#)"


    unsa sayop ani bro...dli man maka save cya data sa database? expert i need ur help
    imong txtid.text kay text mana...

    try using

    dim id as integer
    dim password as character

    id = txtid.text
    password = txtpass.text

    sqlstr = " insert into user_act (id,password,uname,date) Values (id,password,unsame,now())"

    then ngano gamit man ka "&" ?

    kalimot nako ani pero mao raman na ang sql bai..

  4. #34

    Default

    'gamit xa & kay iya mn gideretso gkan textbox, wla xa gamit variable...

    what cbo gamiton? uns on mani kung mag insert na or update mostly dinhi bya mo dala trigger sa error

    'unsay flow diay
    'Cometburn >> i second the motion

  5. #35

    Default

    Quote Originally Posted by emailroy2002 View Post
    imong txtid.text kay text mana...

    try using

    dim id as integer
    dim password as character

    id = txtid.text
    password = txtpass.text

    sqlstr = " insert into user_act (id,password,uname,date) Values (id,password,unsame,now())"

    then ngano gamit man ka "&" ?

    kalimot nako ani pero mao raman na ang sql bai..

    bro, it's the best practice to concatenate strings para sa sql statments, para dili libog asa ang variables.

    Cebujobline.com - Cebu's Free job post

  6. #36

    Default

    Quote Originally Posted by emailroy2002 View Post
    imong txtid.text kay text mana...

    try using

    dim id as integer
    dim password as character

    id = txtid.text
    password = txtpass.text

    sqlstr = " insert into user_act (id,password,uname,date) Values (id,password,unsame,now())"

    then ngano gamit man ka "&" ?

    kalimot nako ani pero mao raman na ang sql bai..

  7. #37

    Default

    Quote Originally Posted by skeptic_rob View Post
    Private Sub cmdsave_Click()
    Dim rs As New ADODB.Recordset
    Dim sqlstr As String

    rs.Open sqlstr, Conn, adOpenDynamic, adLockOptimistic

    sqlstr = " insert into user_act(id,password,uname,date)Values ('"&txtid.text&"','"&txtpassword.text"','"&txtunam e.text&"','#"&txtdate.text&"#)"


    unsa sayop ani bro...dli man maka save cya data sa database? expert i need ur help
    I always wondered why still continue using literal SQL creation rather than using Command and Parameter objects. To avoid this mess, you can always do it like this:

    Code:
    dim cmd as ADODB.Command
    set cmd = new ADODB.Command
    
    set cmd.ActiveConnection = <your_cn_object>
    
    cmd.CommandText = "INSERT INTO <your_table>(Field1,Field2,FieldN) VALUES(pField1,pField2,pFieldN)"
    
    dim p as ADODB.Parameter
    set p = cmd.CreateParameter("pField1", <field_data_type>,, <field_size>, <value>)
    cmd.Parameters.Append p
    
    set p = cmd.CreateParameter("pField2", <field_data_type>,, <field_size>, <value>)
    cmd.Parameters.Append p
    
    set p = cmd.CreateParameter("pFieldN", <field_data_type>,, <field_size>, <value>)
    cmd.Parameters.Append p
    
    cmd.Execute ' Perform save
    No hassles on quotes, hashes to delimit dates, etc. The parameter object will automatically use the correct delimiter based on your database provider. It also protects you from injection attacks. And if you decide to try stored procedures, you could easily just turn the CommandText into Stored Procedure and assign the correct CommandType and your parameters will still stay the same.

    NOTE: ADO is stricter in terms of supplying the correct data type for a parameter, it is even required. Unlike ADO.NET or DAO, the parameter object automatically resolves the data type.

  8. #38

    Default

    @SYNCH: IMHO, Creating a query string is much easier for me and i can do an insert with few lines of code.

    This is an example.

    str = "Insert Into tblPurchaseOrder" & _
    "(PoDate, PTypeID, PoNo, RefNo, SupID, DeliveryDate, EmpID, AppID, Terms) VALUES " & _
    "('" & Format(dtDate, "mm-dd-yyyy") & "'," & _
    "1,'" & Replace(txtPoNo, "'", "`") & "'," & _
    "'" & Replace(txtRef, "'", "`") & "'," & _
    "" & cboSupplier.DataField & ", " & _
    "'" & Format(dtDelivery, "mm-dd-yyyy") & "'," & _
    "" & EmpID & ", " & Comproc.GetField("select AppId from tblApprove where Active = 1") & ", '" & Replace(txtTerms, "'", "`") & "')"

    adoConn.Execute str

  9. #39

    Default

    Quote Originally Posted by Cometburn View Post
    @SYNCH: IMHO, Creating a query string is much easier for me and i can do an insert with few lines of code.

    This is an example.

    str = "Insert Into tblPurchaseOrder" & _
    "(PoDate, PTypeID, PoNo, RefNo, SupID, DeliveryDate, EmpID, AppID, Terms) VALUES " & _
    "('" & Format(dtDate, "mm-dd-yyyy") & "'," & _
    "1,'" & Replace(txtPoNo, "'", "`") & "'," & _
    "'" & Replace(txtRef, "'", "`") & "'," & _
    "" & cboSupplier.DataField & ", " & _
    "'" & Format(dtDelivery, "mm-dd-yyyy") & "'," & _
    "" & EmpID & ", " & Comproc.GetField("select AppId from tblApprove where Active = 1") & ", '" & Replace(txtTerms, "'", "`") & "')"

    adoConn.Execute str
    I always favor someone's code that I can read without twisting my eyes because of missing quotes, etc. Isn't it frustrating when you spent hours of checking/validating the query yet you only missed a quote? This is even harder when months later refactoring/tracing which value maps to which field.

    In your example, if txtRef is of some value like REF1'2, how is it being saved? Aren't you changing the data? Supposedly, Format() shouldn't be used to alter and save dates, let the system handle it for you.

  10. #40

    Default

    So you are saying that the way i do coding is wrong? if So, can you tell me how to correct the way i do insertion on a sql server?
    Last edited by Cometburn; 09-02-2010 at 03:59 PM.

Page 4 of 7 FirstFirst ... 23456 ... LastLast

Similar Threads

 
  1. Samsung gt-s5230 problem
    By scarlet143 in forum General Gizmos & Gadgets Discussion
    Replies: 4
    Last Post: 02-27-2013, 08:37 PM
  2. VB Programming
    By joselyt07 in forum Programming
    Replies: 3
    Last Post: 01-11-2008, 11:53 AM
  3. VB Programming
    By joselyt07 in forum Programming
    Replies: 11
    Last Post: 11-10-2007, 09:30 AM
  4. help on vb programming
    By benz_jie2005 in forum Programming
    Replies: 8
    Last Post: 08-14-2006, 02:00 PM
  5. VB gurus... I need your expertise... problem solve
    By afortaliza in forum Programming
    Replies: 14
    Last Post: 05-23-2006, 09:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top