Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > Still write to database problem


Reply
 
Thread Tools Display Modes
  #1  
Old 08-08-2002, 04:22 AM
cballe
Guest
 
Posts: n/a
Talking Still write to database problem


Hi there guys,

I have posted I problem a week ago and took the advise that I got from all, but still has some small problem with my code. I am going to add the orgininal message to this one, just to give new visitors an idea of what the problem were. The reason why have posted the problem separately again is because time already went by and not everyone goes back to an message that they have already seen and then off course – I also added a sample of the project this time…I have added a sample project just to give you guys an better idea of what could be wrong. Please notice that the fTest Form has only a label on it that displays a percentage – this is because it is just for example purposes and not the original program of mine. It still has to do the same thing. So hope you guys will be able to help me with this one….

PLease put the sample program in foler C:\aa (for database purposes)
Regards
C – Power

Please note the attached file: Sample

Here is the original message:

Hi Guys,

I would appreciate it very much if someone could help me with the following:

I have created a database application by making use of an Ms Access database format (not ODBC). The application consist of the following:

fMain (Main form)
fTest (Second form)
Database: Database name = UserInfo.mdb
TableName: PersInfo

The table has the following fields: User_number,Name, Surname, Test_Result, Date&Time

I have created the first form by making use of the VB Data Form Wizard. Thus, the first page has the following components:

- datPrimaryRS
- picButtons [ New, Add & Proceed buttons]
- three edit boxes were the following must be entered: Name, Surname, Gender


The first form asks the user his personal information like, Name, Surname etc. The user enter his details at the first form (and do not update the database yet) and click on a proceed button to go to the second form. At the second form the user complete a test. After the test is completed, he clicks on a button, btnCompute. The result of the the test are displayed by making use of a label, lblResult.

Now here is were I need help: When the user clicked on the compute button, the results that are displayed by the lblResult (label), must also be written to the database. The database must then be updated so that the final data in the database should look like this:
User_number: 01 (updated otmatically)
Name: James
Surname: Bond
Test Result: 78%
Date&Time: 08/08/2002 12:10

NOTE: As you noticed, the data of the first form (fMain) are part of the data (test result) of the second form (fTest). I need some help on how to do this.

The second problem that I am having is the following:

As part of data in my database, I want to write the system time & date at the moment the update button is clicked. (If possible the system date must also be written to the database) – all together with the details of the user that he have entered at the first form. For example:

Name: James
Surname: Bond
Gender: male
Test Result: 78%
Date&Time: 08/08/2002 12:10


I am not really sure how to implement this – would appreciate some ideas…

JUST TO PROOF TO YOU GUYS THAT I HAVE ACCTUALLY TRIED, HERE IS MY CODE – BUT I AM HAVING PROBLEMS WITH IT:

Sub btnCompute_Click

Dim CurrDateTime as Date
Dim NewRec as ADODB.RecordSet

CurrDateTime = Now()
TestRes = <compute test results>
Set NewRec = New ADODB.RecordSet
With NewRec
.ActiveConnection = frmMain.fADO_Connect
.AddNew
.Fields("Name") = frmMain.txtFirstName.Text
.Fields("SurName") = frmMain.txtSurName.Text
<populate the rest of the fields>
.Fields("Results") = lblResult.Caption
.Fields("TimeOfTest") = CurrDateTime
.Update
End With
Set NewRec = Nothing

End Sub
Attached Files
File Type: zip sample.zip (10.8 KB, 4 views)
Reply With Quote
Reply


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->