question

NadOke-1492 avatar image
0 Votes"
NadOke-1492 asked NadOke-1492 commented

Entering data into SQL via Windows forms in C# continuously with each button click

I started coding for a system to add information of candidates applying for a job to a database and get the total count of the no of candidates applied for each choice since each candidate has been given three choices.

I wrote code for all that but the no of candidates aren't known and I need to create a loop to get the total count. I have used a button to submit the information to the database and it is successful but I have to close the application and come back to enter new data. I NEED TO FIX THIS. I want to add to the database continuously like for example after I enter data the data must be recorded in the database, then when I click the clear button and enter data again and submit I want that to store in the database also and increase the relevant count by 1.

Also, the data will be submitted at different times so the count of the choices must not go back to 0 once the application is closed.

I'm new to C# so I'm lost. PLEASE HELP ME SOLVE THIS PROBLEM.

small-basic
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JanWieldraaijer-1495 avatar image
0 Votes"
JanWieldraaijer-1495 answered NadOke-1492 commented

As a start, the following program works in Small Basic. You can follow the logic to write your C# program

 fileout=Program.Directory+"\test.txt"
    
 ''read the number of records in the file
 Nrec=1
 dummy=file.ReadLine(fileout,1)
 while dummy<>""
   Nrec=Nrec+1
   dummy=file.ReadLine(fileout,Nrec)
 EndWhile
 Nrec=Nrec-1
 TextWindow.WriteLine("The number of records in file "+fileout+" is : "+Nrec)
 TextWindow.WriteLine("")
    
 Nfield=3  ''number of fields in data record
 stop=0
 while stop=0
   for ifield=1 to Nfield  
     TextWindow.Write("give contents of field "+ifield+"  [STOP to end input] : ")
     field[ifield]=TextWindow.Read()
     if field[ifield]="STOP" Then
       ifield=9999
       stop=1
     EndIf
   EndFor
   if stop=0 Then
     Nrec=Nrec+1
     File.AppendContents(fileout,field)
     TextWindow.WriteLine("Record "+Nrec+" written")
   EndIf
   TextWindow.WriteLine("")
 EndWhile
    
 TextWindow.WriteLine("The file "+fileout+" contains now "+Nrec+" records")
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank You I'll try this

0 Votes 0 ·
JanWieldraaijer-1495 avatar image
0 Votes"
JanWieldraaijer-1495 answered NadOke-1492 commented

If you want an answer for a C# question, it doesn't help to ask that in a forum about the Small Basic language. Try to find a C# forum.

I can help you if you want to progrm your problom in Small Basic.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.