User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 392,083 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,952 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser:
Views: 4563 | Replies: 2
Reply
Join Date: Jan 2007
Posts: 2
Reputation: Nosipho is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Nosipho Nosipho is offline Offline
Newbie Poster

Update SQL database automatically using VB6

  #1  
Jan 31st, 2007
Can someone please show me a code syntax on how to update an SQL database programmatically ( execute on click of button).

I want to get all records from the "Student" database table where StudentStatus = 'New'' .Find a particular RegDate (2001/02/02) , StudNo ( 200144176) and update it's StudentStatus to "Öld", by clicking a command button ( UpdateDatabase). I'm using SQL2000( Windows Authentication).

and please show me how to connect or retreive that information from the database .

Hope I make sense.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2007
Posts: 1
Reputation: swayo is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
swayo swayo is offline Offline
Newbie Poster

Solution Re: Update SQL database automatically using VB6

  #2  
Feb 2nd, 2007
Originally Posted by Nosipho View Post
Can someone please show me a code syntax on how to update an SQL database programmatically ( execute on click of button).

I want to get all records from the "Student" database table where StudentStatus = 'New'' .Find a particular RegDate (2001/02/02) , StudNo ( 200144176) and update it's StudentStatus to "Öld", by clicking a command button ( UpdateDatabase). I'm using SQL2000( Windows Authentication).

and please show me how to connect or retreive that information from the database .

Hope I make sense.


'This is a quick example of an ADO recordset that does what you want.

'These 2 items would be moved to a global area
Dim gstrStudNo As String
Dim gdatRegDat As Date

'This just fills the 2 items above, you would fill them some other way
gstrStudNo = "111234234"
gdatRegDat = #3/23/2004#

'Create Connection Object to SQL server table
Dim con As ADODB.Connection
Set con = New ADODB.Connection
con.ConnectionString = gstrDSN 'this global string contains the DSN like "DSN=SomeName;"
con.Open
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.CursorType = adOpenStatic
rst.LockType = adLockOptimistic
rst.ActiveConnection = con
'next line assumes the StudentStatus you want is always 'New' but the other 2 items are variable
rst.Source = "SELECT StudentStatus FROM Students WHERE StudentStatus = 'New' And StudNo = '" & gstrStudNo & "' And RegDate =#" & gdatRegDat & "#"
rst.Open Options:=adCmdText

Do While Not rst.EOF
rstStudentStatus = "Old"
rst.Update
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
con.Close
Set con = Nothing
Reply With Quote  
Join Date: Jan 2007
Posts: 2
Reputation: Nosipho is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Nosipho Nosipho is offline Offline
Newbie Poster

Re: Update SQL database automatically using VB6

  #3  
Feb 5th, 2007
thank you ,thank you, thank you that's exactly what I needed

thank you so much.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Visual Basic 4 / 5 / 6 Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum

All times are GMT -4. The time now is 12:23 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC