返回首页

DataTable dt = new DataTable();

 

                        dt.Columns.Add("L_DateTime");

                        dt.Columns.Add("L_Direction");

                        dt.Columns.Add("L_CardID");

                        dt.Columns.Add("L_GateID");

 

                        int i2 = 0;

                        while ((inputLine = rdr.ReadLine()) != null) //Read while                          

                                                 //the line is not null

                        {

                            string[] arr;

                            arr = inputLine.Split(','); //splitting the line which

   

                           //was read by the stream reader object



                            row = dt.NewRow();

                            row["L_DateTime"] = Convert.ToDateTime(arr[0]);

                            row["L_Direction"] = arr[1];

                            row["L_CardID"] = arr[2];

                            row["L_GateID"] = Convert.ToInt32(arr[3]);

 

                            dt.Rows.Add(row);

                            i2++;

                        }

 

                        sqlbulkCopy.WriteToServer(dt);

                        sqlbulkCopy.Close();
问候大家...我有问题就在这里...
让我解释一下这是什么代码是所有关于...

IM使用sqlbulk从文本文件中读取数据,并存储在数据库中。至于IM文本文件,所有的数据作为字符串处理(或许)!......

早在我的数据库我已经创建了名字正是在这段代码中的行..

第一次在我的SQL DBASE,IM当作字符串的所有数据......它做工精细..
但是,因为它涉及的datetime ...我改变它合适的类型...
我strting得到错误...说:!!字符串未被认可为有效的DateTime
我不明白...我已经将它转换为datetime ...任何建议,将是很好的....至于所有编码!!

回答

评论会员: 时间:2