Results 1 to 10 of 10

Thread: Update Sql

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2005
    Location
    Greece
    Posts
    61

    Unhappy Update Sql

    Hi

    Is there any example how I can update a record in my table of
    one sql 2000 database?
    Can I doit throu sql script?
    My database name is promithies and the table is choose.

    Thank you for your help.

  2. #2
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Update Sql

    Connect to the database using ADO connection and then Execute an Update statement like you would do it in a simple query analyzer.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2005
    Location
    Greece
    Posts
    61

    Re: Update Sql

    I did that but I get error on open command why?

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,501

    Re: Update Sql

    As with most errors... without seeing your code and the error message we could only guess.

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,692

    Re: Update Sql

    For one thing, you should be using connection.execute, not recordset.open.

  6. #6
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Location
    Sharjah, United Arab Emirates
    Posts
    3,031

    Re: Update Sql

    even recordset.open also will help if it is opened with adOpenKeyset thats not a problem...
    but he has to post his code to analyse
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.


  7. #7

    Thread Starter
    Member
    Join Date
    Nov 2005
    Location
    Greece
    Posts
    61

    Re: Update Sql

    Ok
    I understend here is the code

    Dim cnConn As ADODB.Connection
    Dim Rs As ADODB.Recordset
    Dim strsql As String

    Set cnConn = New ADODB.Connection
    Set Rs = New ADODB.Recordset

    With cnConn
    .Provider = "SQLOLEDB.1"
    .Properties("Data Source").Value = "server"
    .Properties("User ID").Value = "clroot"
    .Properties("Password").Value = "clroot"
    .Properties("Initial Catalog").Value = "promithies"
    .CursorLocation = adUseClient
    .ConnectionTimeout = 0
    .Open
    End With

    strsql = "update choose " & _
    "set timi1=CAST('" & txttimi1.Text & "' as decimal(10,4))" & _
    ", onoma1='" & txtonoma1.Text & "'" & _
    ", apo1='" & Date & "'"

    MsgBox (strsql)

    Rs.Open strsql, cnConn, adOpenStatic, adLockOptimistic

  8. #8
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Update Sql

    Why would you use Rs.Open to execute an Update Query. You should be using [code]cnConn.Execute strsql[/Highlight] Thats it.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  9. #9

    Thread Starter
    Member
    Join Date
    Nov 2005
    Location
    Greece
    Posts
    61

    Re: Update Sql

    OK thank you the problem is solved.

    One more think Depnding of regional settings my decimal number format
    is stored with , and not with . for example 123,45

    I think that there is a format command that change that.
    I mean to change the , with . for example to change the 123,45
    with 123.45

    thank you

  10. #10
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: Update Sql

    You could use Replace to replace the , with a .

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