Results 1 to 11 of 11

Thread: [RESOLVED] i have error saving in database

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2013
    Posts
    6

    Resolved [RESOLVED] i have error saving in database

    hello guys,

    please help me to fix my problem.. i am trying to add record in my database in mysql.. i have this codes below:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    rs = New ADODB.Recordset
    rs.Open("insert into employee values('" & txtid.Text & "','" & txtname.Text & "','" & txtaddress.Text & "','" & cmbgender.Text & "','" & DateTimePicker1. Text & "')", Mycon, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)
    MsgBox("save agad")
    End Sub

    when i run it an error shows like this:

    System.Runtime.InteropServices.COMException was unhandled
    ErrorCode=-2147217887
    Message="ODBC driver does not support the requested properties."
    Source="Microsoft OLE DB Provider for ODBC Drivers"

    i don't know how to solve this because i used this code already in other project and it worked..

    is anyone know how to solve this??

    help. . . .

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: i have error saving in database

    Sounds like you are using the wrong connection string.

    Also you should be using ADO.Net rather than ADODB

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,415

    Re: i have error saving in database

    Quote Originally Posted by DataMiser View Post
    Sounds like you are using the wrong connection string.

    Also you should be using ADO.Net rather than ADODB
    as DataMiser said, use ADO.Net instead of the superceded ADODB

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,104

    Re: i have error saving in database

    The best answer is certainly to get away from ADODB in favor of the newer, but if that is in someway impractical, then you're going to have to do a bit of detective work. Database errors like this can be rather opaque in that the error message doesn't really tell you what the problem is in a very specific sense. Something isn't supported, maybe, but what? Is it just a typo, or is one of your arguments wrong? You don't get much information about that.

    Unfortunately for you, since ADODB is so dated, few people will have much experience with it in .NET. But you DO have some experience with it, since, according to you, this code worked in a different program. So, what is different between the two? Because that's where your problem lies. Are both programs on the same computer (and if not, is one on a 64-bit while the other is not)? Are you using the same arguments? Something has to be different or else both would behave the same.
    My usual boring signature: Nothing

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2013
    Posts
    6

    Re: i have error saving in database

    i am currently using it here in my laptop means that this is not different bits (32 bit/64 bit) the first program i used is work, it is about adding and generating serialcode in database.. what i was edited here is only the names of table and columns.

    anyway, how can i change it into ado.net connection?


    thanks guys for reading my post.. thanks for helping also.. i am a new member here and a new student in vb.net

  6. #6
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: i have error saving in database

    Instead of using the OLE DB driver he should be using a MySql driver. I would think that is the most likely candidate.

    From a connection string I have used to connect to MySql using ADODB from Vb6

    DRIVER={MySQL ODBC 3.51 Driver}

  7. #7
    Lively Member
    Join Date
    Apr 2011
    Posts
    75

    Re: i have error saving in database

    And whatever you do, beware of SQL Injection. The user could type in all sorts of nasty things in the text boxes that would end up as SQL commands. Use parameters instead.

  8. #8

    Thread Starter
    New Member
    Join Date
    Feb 2013
    Posts
    6

    Re: i have error saving in database

    guys, do i have to use the ado.net connection?

    what line in my code should i change if i revise it into ado.net?

    thanks..

  9. #9
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: i have error saving in database

    You would change all of the lines related to database access.

  10. #10
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,415

    Re: i have error saving in database


  11. #11

    Thread Starter
    New Member
    Join Date
    Feb 2013
    Posts
    6

    Re: i have error saving in database

    guys i found the already the error.. it works now i just edit the connection string.. thanks for those who response to my post..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width