Can we insert Multiple check box Values in One Column? - asp.net

i wan to insert multiple selected checkbox values to be inserted in to one column, can we do this. and if we can do it? please let me know how to do it......
thank you..

You could take all of the values and append them to a stringbuilder and then submit that to your db column

Use a Flags-type enum and store the integer value in the column.

If you want to want to have these 'multiple check boxes' values predefined then create a separate table for it. Otherwise if they are random, then there shouldn't be a problem. Just read them, append in a string and pass it to database.

You can use separator (like $,:,#...) to combine check boxes value and make one string and insert in to column. And when you want to retrieve that value just spilt that string.

Related

PhpExcel Dynamic Header in first Row

I have below SQL and I want to write field values in first row and rest of the row and values. How do I achieve using PHPEXCEL.
Can someone post full example.
I found so many example how to write fixed rows when you know the field name but without knowing field name I like to print header in first row and rest as values.
$query = "SELECT * FROM uam_user";

Chnage table Name and Its Field Name Also Without missing any Data In Sqlite

I have created one table 'Temp1'. with fields "id,pName,pid" etc.
but i want to Replace this table name with 'temp2' and fields name aslo with "no,name,rollno" without any data loss.
and also add one extra column compName in new created table Temp2.
can any one help me how i can achieve this.
Plz Help me.
Thanx in advance.
CREATE TABLE temp2 (no, name, rollno);
INSERT INTO temp2 SELECT id, pname, pid FROM temp1;
I assumed no datatypes or constraints on columns, so you need to adjust if you want some constraints.
Now you can verify that you have all the data in new table. Then, if you no longer need Temp1, you can drop it:
DROP TABLE temp1;
and if you want to shrink database (remove unused parts of the database file):
VACUUM;

Remove "TRIM" in a column field?

Referring to the question above, I have a problem when I'm trying to display my database in datagridview. I have a field "Items" but when I call it to the grid, the field will be name "TRIM(Items)". The "TRIM" comes from my sql statement :-
SELECT TRIM(Items) FROM others2
I need the TRIM so that there is no space when I called my data to the grid.
Anyway, how to remove the word but still it will trim my data?
Try SELECT TRIM(Items) As Items FROM others2.

problem in DataTextField with non simple return value

I know that the syntax for using DataTextField is:
VA.DataTextField = "nameofcolum"
but if my request is not simple that means my request returns the result in a column which not exist in this case. What I should to affect to DataTextField?
It's hard to tell what you're looking for here without more information.
If your result set does not contain the column you need, change your result set - alter your query. If you need your datatextfield as a combination of columns, you can iterate through the result set and build the text string based on the column values and assign it as the display value.

Converting DateTime data to String in dataset

I have a dataset which stores dates in a DataColumn (datatype of this column is DateTime). I need to change the format from DateTime to string that will give me the date as per my current culture.
In case of a single DateTime variable, I can use the overloaded ToString() to achieve this in the following manner:
DateTime.Now.ToString(System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern)
But I need to convert data for all the rows in my DataSet to string. Does anyone have an idea on how I can achieve this?
Thanks.
When you get the DataSet:
locate apropriate DataTable
add new DataColumn
in one loop you populate new Column with (your DateTime).ToString()
Get the Dataset.
for each row convert to string and
put it in new dataset (along with
rest of data).
I don't think it's possible to change a column type after the table been filled. I think you should create a second table on your dataset and copy the information you need transforming the date in the process.
New answer :)
I have been googling an came up with this site: Linq to Dataset
That example shows how you can use linq on a dataset, I am guessing that you could use a query to perform the data transformation and place it on the new datatable. Not sure if it will perform better then the loop
If I were you, I would keep the data in the DataTable as it is. It is after all, meaningful data that would lose its meaning upon conversion. I would make any desired modifications only when displaying/rendering the data because that implicitly requires a conversion of the data into strings (with optional formatting).
Any DateTime variable can be rendered as a string (with culture-sensitive formatting) using the simple code:
DateTime.Now.ToShortDateString();
// Or
DateTime.Now.ToString("d");
This function already uses formatting information derived from the current culture.
I really would suggest that you take another look at your scenario to evaluate if you really need to change the datatype of data in the dataset itself. (or provide us with more information)

Resources