|
|
Hi,
How to insert a bulk data from a datatable or dataset or datagrid into database in a single click.
Thankyou
YPKI
|
|
|
|
|
Add all rows to the datatable. Then use sqlbulkcopy.It inserts all the records into database table in one shot.
SqlConnection destinationConnection = new SqlConnection(strConnection);
destinationConnection.Open();
SqlBulkCopy bulkCopy = new SqlBulkCopy(destinationConnection );
bulkCopy.DestinationTableName = "destination";
bulkCopy.WriteToServer(yourDatatable);
destinationConnection .Close();
|
|
|
|
|
Hi,
How to insert a bulk data from a datatable or dataset or datagrid into database in a single click.
Thankyou
YPKI
|
|
|
|
|
You've asked the same question twice - a big no-no! Delete one of them.
In the meantime what have you already tried/researched for yourself?
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
Hi all i have binded data with gridview in presention point view it is working but while inserting the data to DB and iam traversing the girdview iam getting the index missing . please guide me where iam doing wrong
DataTable dataTable = new DataTable();
dataTable.Columns.Add(new DataColumn("StudentID", Type.GetType("System.String")));
dataTable.Columns.Add(new DataColumn("StudentName", Type.GetType"System.String")));
dataTable.Columns.Add(new DataColumn("MajorName", Type.GetType("System.String")));
dataTable.Columns.Add(new DataColumn("StudenMarks", Type.GetType("System.Int16")));
dataTable.Rows.Add(new string[] { "1","Student1","English"});
dataTable.Rows.Add(new string[] {"2", "Student2","English"});
dataTable.Rows.Add(new string[] { "3","Student3","Hindi"});
dataTable.Rows.Add(new string[] { "4", "Student4","Hindi"});
dataTable.Rows.Add(new string[] { "5", "Student4","Hindi"});
GridView1.DataSource = dataTable;
GridView1.DataBind();
AND my gridview looks like the below
<asp:gridview id="GridView1" runat="server" autogeneratecolumns="false" onrowdatabound="GridView1_RowDataBound"
="" ondatabound="GridView1_DataBound">
<columns>
<asp:boundfield datafield="StudentID" headertext="Student ID">
<asp:boundfield datafield="StudentName" headertext="Student Name">
<asp:templatefield headertext="Major Name">
<itemtemplate>
<asp:label id="lblTypeName" runat="server" text="<%# Eval("MajorName") %>">
<asp:templatefield headertext="Marks">
<itemtemplate>
<asp:textbox id="txtMarks" runat="server" class="calculate" onkeyup="calculate()"
="" width="95%">
<asp:templatefield headertext="Sub-Total">
<itemtemplate>
<asp:label id="lblSubTotal" runat="server" class="SubTotal">
And on Row Data bound event i have the below code
string tmpCategoryName = string.empty;
protected void GridView1_RowDataBound (object sender, GridViewRowEventArgs e)
{
// If the current row is a DataRow (and not a Header or Footer row), then do stuff.
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView drv = (DataRowView)e.Row.DataItem;
if (tmpCategoryName != drv["MajorName"].ToString())
{
tmpCategoryName = drv["MajorName"].ToString();
// Get a reference to the current row's Parent, which is the Gridview (which happens to be a table)
//Table tbl = e.Row.Parent as Table;
Table tbl = e.Row.Parent as Table;
if (tbl != null)
{
GridViewRow row = new GridViewRow(-1, -1, DataControlRowType.DataRow, DataControlRowState.Normal);
TableCell cell = new TableCell();
// Span the row across all of the columns in the Gridview
cell.ColumnSpan = this.grdProduction.Columns.Count;
cell.Width = Unit.Percentage(100);
cell.Style.Add("font-weight", "bold");
cell.Style.Add("text-align", "center");
HtmlGenericControl span = new HtmlGenericControl("span");
span.InnerHtml = "(" + tmpCategoryName + ")";
cell.Controls.Add(span);
row.Cells.Add(cell);
tbl.Rows.AddAt(tbl.Rows.Count - 1, row);
}
}
} }
OUTPUT while getting the data from Gridview
100 1 StudentName1
2
200 3 StudentName 2
300 4 StudentName 3
400 5 StudentName 4
but when iam going to insert the data from gridview to Database on button click iam getting the Invalid data index missing ( Invalid data entry as well)
Regards,
|
|
|
|
|
"Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: index" in datagrid1 after clicking the data
any one can help me to sort out
rizvan sivally
|
|
|
|
|
sheemap wrote: any one can help me to sort out
Of course I can. Oh, wait, telepathic powers waning... can't quite make out what you need...
You need to be a wee bit more specific - not enough to properly assess what you need though this[^] might point you in the right direction.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
After selecting what data you are getting this exception..?? show your code..
with regards
Karthik Harve
|
|
|
|
|
share your code.
When I face this problem,it is due to
I have two gridviews
and on click of second gridview linkbutton, I was using First gridview index.Thats the mistake.
FOr Gridview2 I was used
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = GridView1.Rows[index];
so ckeck for same.
|
|
|
|
|
show data of table1 of datagrid1 to datagrid2
how this is possible
rizvan sivally
|
|
|
|
|
make it clear to understand,so that we can give you an appropriate solution..
|
|
|
|
|
what do you mean by this. "table1 of datagrid1". is it Page 1 of datagrid1..?? mention clearly..
with regards
Karthik Harve
|
|
|
|
|
I want to use the visio activeX contorl in asp.net. Form where i can drawing the diagram.
hi
|
|
|
|
|
|
While searching code project articles on security. I found this article The Art and Science of Storing Passwords The rating for this article is very good, however the date is quite old. So I would like opinion's on the methods used in this article.
Thanks in advance
[edit] Fixed article title and format [/edit]
Frazzle the name say's it all
|
|
|
|
|
|
Though it was old article but the method is very good...you can try it.
Thank you
|
|
|
|
|
The methods haven't changed much in the last 20 years.
But the more secure you make your program, the more you realize that it can still be hacked, to an infinite point of thought.
Do the binary hash, and make a copy that is encrypted, or just the hash and a password reset, make a new hash.
|
|
|
|
|
Thanks for answering My post. I think I will store the salted hash and email a temp link for password reset.
I can try to make it somewhat secure that way.
Frazzle the name say's it all
|
|
|
|
|
That's how I started. Later on down the road, you'll need something else, and you can add it then.
|
|
|
|
|
Out of curiosity what more can I do? If You know of some learning resources I can use like books or links I would be most grateful.
Thanks in advance
Frazzle the name say's it all
|
|
|
|
|
The main goal is to obscure the password in the database in case someone gets a peek at it. Now you can encrypt the username, so if someone peeks, they can't put the 2 together.
You can encrypt the email address, so it is a mystery as to who it is.
On the customer service side, people will say I lost my password. Or what is my husbands password, assuming the husband uses the same password, so they can access his email.
Or people will forget their password, because they were drinking when they created the account, thus the password reset.
OK, so your all encrypted to the max, a programmer just needs the code, the key, and perhaps the IV to decrypt the data.
Is your data file protected, from internal or external theft? Can someone on the internet figure out how to steal it online.
It goes on and on and on.
|
|
|
|
|
hi
i am having the following function in javascript:
function passvalue() {
var editor = $find("<%=Editor1.ClientID%>");
var content = editor.get_content();
window.opener.document.getElementById("ctl00_cphMain_txtEditor").value = content;
self.close();
}
in this function in am getting the editor contents but all are in html format.
can anyone plz tell me how to convert the contents into plain text.
K.Gayathri
|
|
|
|
|
var nonHTMLcontent = document.getElementById(ControlIdContainsHTMLContent).contentWindow.document.execCommand("RemoveFormat",false,null)
Here
ControlIdContainsHTMLContent contains HTML content. In
nonHTMLcontent variable you will get content after removing formatting.
Hope this will help.
Regards...
Vijay Jain
"One thing you can't recycle is wasted time."
|
|
|
|