网格数据到数据库 [英] griddata to database

查看:66
本文介绍了网格数据到数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用excel上传的文件.我在gridview中显示了该文件.
现在我想在数据库中显示它.我的意思是将数据存储在数据库中.
请帮助我

i am using excel uploaded file.and i displayed that file in gridview.
Now i want to show it in database.i mean to store that data in database.
plz help me

推荐答案

您应该将Excel文件数据保存在DataTable或任何其他对象中.从那里获取数据,然后通过ADO.Net代码将其发送到数据库.
You should be having the excel file data in a DataTable or any other object. Get the data from there and send it to database through ADO.Net code.


您可以将excel文件的路径传递到存储的proc并使用BULK INSERT将excel中的所有数据插入表
You can pass path to your excel file to stored proc and use BULK INSERT to insert all data from your excel into table



我也接受第二个答案...
但是如果您想以自己的方式存储数据,请尝试以下操作

Hi
I also accept the 2nd answer...
but if you want to store data in your way try this

for (int i = 0; i < (Datagrid.RowCount - 1); i++)
{

    column1 = DataGrid.Rows[i].Cells[0].Value.ToString();
    column2 = DataGrid.Rows[i].Cells[1].Value.ToString();
    //your code for insert data into database
}



您可以逐行添加数据.

谢谢.



you can add data row by row..

Thanks..


这篇关于网格数据到数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆