Page 2 of 7 FirstFirst 12345 ... LastLast
Results 11 to 20 of 69
  1. #11

    Code:
    " insert into user_act(id,password,uname,date)Values ('"&txtid.text&"','"&txtpassword.text"','"&txtunam e.text&"','#"&txtdate.text&"#)"
    this statement in your first post, if "id" column has numeric datatype then in your VALUES clause you enclosed the value to be inserted into "id" column in single quotes, it will be treated as a char/string value. i dunno if vb or your db will do some data coersion if not then that might cause a data type mismatch that is if "id" column is numeric.

    Code:
    "INSERT INTO user_act(id,password,uname) VALUES '" & Val(txtid.Text) & "','" & Left(txtpassword.Text, 20) & "'," & Left(txtuname.Text, 50) & ")"
    in this statement you lacked "(" after the VALUES keyword hence the syntax error

    btw, you might want to post the data types of the columns in your USER_ACT table.

    also, is this the only way to do an INSERT sql in vb? if you can find another way please do so. not only is this an ugly way it's also error-prone. statements like these are also vulnerable to sql injections specially since you are concatenating values taken straight from your input fields. might not be true in this particular insert statement but if you get used to these type of sql coding you might come up with vulnerable code. just a thought.

  2. #12
    Private Sub cmdsave_Click()
    Dim rs As New ADODB.Recordset
    Dim sqlstr As String

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


    rs.Open sqlstr, Conn, adOpenDynamic, adLockOptimistic

    @: try daw ni daw ni bro, naa kay ka na miss pag concatenate... then the value of your variable sqlstr should be declared before your ado open statement.... please alaso check datatype of the column id.. try lang kay I havnt tested this code.

    suggestion: if your using MSSQL, try stored procedures bro.. its fast and secured!

  3. #13
    Elite Member
    Join Date
    Jun 2010
    Gender
    Male
    Posts
    1,018
    Quote Originally Posted by skeptic_rob View Post
    iyang error data type mismatch daw in criteria expression...im not to familiar with the syntax error..
    Kung type mismatch...
    suwayi og tang2x single quotes sa id...kay tingali number na...

    Kung dili au hassle para nimo...
    try to research on prepared statements para dili ka mabuang og string concatenate

    Lastly, tarong og parse imong date... it needs sakto nga format... or else ang iya mabasa sayop like ang first 2 number lang mao mahimong int... unya mureklamo dayon og type mismatch

  4. #14
    still not working .. i don't know what is the reason behind this code....ahak oist wala pa gud na solve

  5. #15
    test thy waters. Don't stop.

  6. #16
    Elite Member
    Join Date
    Jun 2010
    Gender
    Male
    Posts
    1,018
    What have you tried so far? Kung naay errors...could you post the errors as well?

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

    suwayi daw ni na code bro. hope this one will work.. akoa lang gi fix imohang code. medyo naa lay kulang sa imong code and naa lang say giusab gamay.

    be sure lang sad nga inig sud nimo sa record labi na ang date if empty ang textbox puede ra null imong i sud as long as naka set og nullable ang column. try to be sure lang pod nga sa imong user_act(id,password,uname,date) kana nga mga columns naa sa imohang table or spell correctly.

    no need na you put # sign inig sud nimo sa record. you need it lang kung mag condition ka, (eg..mag compare ka ug date) .

    try lang code sa taas then if no effect japon post lang kung unsay error nya...

  8. #18
    try daw ug echo imong insert bro...

    Code:
        sqlstr = "insert into user_act(id,password,uname,date) Values ('"& txtid.text & "','" & txtpassword.text &"', '" & txtuname.text & "', '" & txtdate.text & "' )"
        msgbox sqlstr
    dn manual lng ka ug insert, dn post sa error message ngari

    dn better follow sa mga comments nila ni doddie, ky syntax error imong insert statement

  9. #19
    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
    ibutang sa babaw ang sqlstr initialization nimo....like so...

    Code:
    Dim rs As New ADODB.Recordset
    Dim sqlstr As String
    
    sqlstr = " insert into user_act(id,password,uname,date)Values ('"&txtid.text&"','"&txtpassword.text&"','"&txtuname.text&"','#"&txtdate.text&"#')"
    
    rs.Open sqlstr, Conn, adOpenDynamic, adLockOptimistic
    notice the characters in red in your sql statement, those are the missing ones!!!

    hope this helps...

  10. #20
    I already solve this program but the problem is ..it cannot store data nasad

  11.    Advertisement

Page 2 of 7 FirstFirst 12345 ... 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