| | |
Update SQL database automatically using VB6
![]() |
•
•
Join Date: Jan 2007
Posts: 2
Reputation:
Solved Threads: 0
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.
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.
•
•
Join Date: Feb 2007
Posts: 1
Reputation:
Solved Threads: 0
•
•
•
•
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.
'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
![]() |
Similar Threads
- SQL, Dataview, DataTable and DataAdapter.Update (VB.NET)
- Problem Inserting into SQL database on server (ASP.NET)
- Plz Help:If IE closed without signout how to update SQL to set user status (ASP.NET)
- Problem with update data to database (JSP)
- Process very slow - SQL Database (MS SQL)
- Help with Roles Stored in SQL database (ASP.NET)
- Snyc'n Local SQL database online (MS SQL)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Code for Call the program in Visual Basic
- Next Thread: storing a calendar in VB to Oracle
| Thread Tools | Search this Thread |
* 6 2007 access activex add age basic beginner birth bmp calculator cd cells.find click client code college connection connectionproblemusingvb6usingoledb creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit excel excelmacro file filename form header iamthwee image inboxinvb internetfiledownload listbox listview liveperson login looping microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading remotesqlserverdatabase report save search sendbyte sites sql sql2008 sqlserver subroutine tags time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web windows





