Page 1 of 7 1234 ... LastLast
Results 1 to 10 of 69
  1. #1

    Default vb program insert into >>problem


    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

  2. #2
    You have to be careful with QUOTES single ' or double " . Make sure they are not in conflict.

    Proper use of concatination and string manipulation. Use escape characters like \" or \' depends on which QUOTE container you are using.

    *SQL itself is using QUOTES for values.
    *Programming language like VB is also using QUOTES to manipulate strings.

    Be sure that your syntaxes are not in conflict at the final output. Use logging or debugging techniques to monitor your activity.

    I see something missing here..
    Code:
    ('"&txtid.text&"','"&txtpassword.text"','"&txtuname.text&"','#"&txtdate.text&"#)"
    Last edited by dodie; 06-26-2010 at 02:04 PM.

  3. #3
    try to manually insert through your code... kanang sure jud ka nga maka insert ayaw sa nang via textboxes or unsa, then ayha i hinay2x ug replace... and yes, usually, ang quotes maoy mo dala ug yagaw...

  4. #4
    i limpyo gamay imo codes bro.. malipat jud ka ana kay sigkit ra kaayu... pahamak sad baya kaayu na ang quotes... mao jud na masayupan nako... then pag open nimo sa imo recordset mas maayu sa form load na nimo ibutang para kaisa ra

  5. #5
    Dim rs As New ADODB.Recordset
    Dim rsRet As New ADODB.Recordset
    Dim sqlStr As String

    If NewEdit = 0 Then 'Insert New record

    sqlStr = "SELECT * FROM user_act WHERE id='" & txtid.Text & "'"
    rsRet.Open sqlStr, Conn, adOpenForwardOnly, adLockReadOnly

    If rsRet.EOF Then
    rsRet.Close
    sqlStr = "INSERT INTO user_act(id,password,uname) VALUES '" & Val(txtid.Text) & "','" & Left(txtpassword.Text, 20) & "'," & Left(txtuname.Text, 50) & ")"
    rs.Open sqlStr, Conn, adOpenDynamic, adLockOptimistic

    MsgBox "One record saved!", vbInformation, Me.Caption
    rsRet.Close
    MsgBox "Duplicate Stock Code. Please review your entries!!", vbCritical, Me.Caption
    End If
    End If

  6. #6
    iyang error data type mismatch daw in criteria expression...im not to familiar with the syntax error..

  7. #7
    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
    syntax error in INSERT INTO statement

  8. #8
    Quote Originally Posted by skeptic_rob View Post
    Private Sub cmdsave_Click()


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

    try force insert daw, sqlstr = " insert into user_act(id,password,uname,date)Values ('a','b','c',2010-06-2 kung mo sugot ba cya... more on the datatype sa imong i insert ang ga conflict...

  9. #9
    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
    bro... see dodie's post... and try it... or try this sqlString

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

  10. #10
    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
    unsay gamit nimo ani nga database?

    try to change the date sa imo dbase like sDate... kay nag.sa mag.conflict na sila sa dbase command ug ang field declaration

    i hope makatabang ang ako idea

  11.    Advertisement

Page 1 of 7 1234 ... 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