Q) We have 4 text boxes to take input but we hav only one column in our database. How to insert the text of 4 different text boxes in to a single column of database(occupying 4 rows) one after the other.

[ 4 ur understanding I m explaining the scenario: when a teacher is uploading the test he/she will enter the question, the correct ans and the 4 choices but we hav only one column for choices not 4 different columns. We hav decided that we will save each choice accordig to quest id like for question 1 we have 4 rows, for question 2 we hav another 2 rows…… hope u r getting what im trying to say]

Q) how to keep track of no. of records entered by that time i.e every time when a new record is entered , the count shuld not get re-initialized but it shuld increment in the last value it had stroed in it.


many thanks..

ariez88,
A) Concatenate value of four textboxes.
A) Use trigger, sequence, AutoNumber etc.

Assuming you are using MSSQL (based on your other posts) you can create a new table with an identity like this:

IF OBJECT_ID('TestTable123', 'U') IS NOT NULL DROP TABLE TestTable123
Create Table TestTable123
(
  SerialNumber int identity(1000, 1),
  Column1 varchar(20)
)

This example creates a new table (to simulate an existing table) then uses Alter Table to add an identity column to the existing table:

IF OBJECT_ID('TestTable123', 'U') IS NOT NULL DROP TABLE TestTable123
--Create the simulated existing table
Create Table TestTable123
(
  Column1 varchar(20)
)

--Make sure the table exists and the column SerialNumber doesnt
IF OBJECT_ID('TestTable123', 'U') IS NOT NULL AND NOT EXISTS(Select * From syscolumns Where ID = OBJECT_ID('TestTable123', 'U') and name = 'SerialNumber')
BEGIN
  --Add a new identity column
  Alter Table TestTable123 Add SerialNumber int identity(1000, 1)
END

Based on your question i guess that you are in the initial stage of this project. So why you do not modify your your database design. If you don't do this at that stage after few days you will suffer a lot.

Specially your queries will be more complex if you do not maintain entity relationship. My comment is redisgn your database.

commented: agreed +4
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.