MyException - 我的异常网
当前位置:我的异常网» C# » 还是关于sql批量导入的有关问题,求指教

还是关于sql批量导入的有关问题,求指教(3)

www.MyException.Cn  网友分享于:2013-02-20  浏览:10次


                     // MessageBox.Show(a[v1] + "\n" + zy, c1, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        zy=zy+1;
                     }

                    SqlConnection cocn = new SqlConnection("data source = .;initial catalog = School; user id = sa;password = 4380364054;database=School");
                    //  string connStr="data source = .;initial catalog = School; user id = sa;password = 4380364054";
                  
                 // SqlConnection conn=new SqlConnection(connStr);
                 //SqlConnection conn=new SqlConnection(coon);
                  cocn.Open();
                  SqlCommand cmd = cocn.CreateCommand();
                  cmd.CommandText= "insert into Student"+"(StuNo,StuName,ClassID,StuSex,StuBornDate,StuNation,Status,IdentityCard,StuFrom,StuPhone,FamilyPhone,StuAddress,BeginTime)"+
                      "values (@iStuNo,@iStuName,@iClassID,@iStuSex,@iStuBornDate,@iStuNation,@iStatus,@iIdentityCard,@iStuFrom,@iStuPhone,@iFamilyPhone,@iStuAddress,@iBeginTime)"; 
                 // SqlCommand cmdzx=new SqlCommand(sql,conn);//
                // string   sql1= "insert into users(Name,Age,Sex,Pwd)values (@myName,@myAge,@mySex,@myPwd)"; 
              // SqlCommand cmd1=new SqlCommand(sql,conn);//conn请自行给出

                      //SqlCommand cmd = conn.CreateCommand();
                      cmd.Parameters.Add("@iStuNo", SqlDbType.VarChar);
                      cmd.Parameters.Add("@iStuName", SqlDbType.VarChar);
                      cmd.Parameters.Add("@iClassID", SqlDbType.Int);
                      cmd.Parameters.Add("@iStuSex", SqlDbType.VarChar);

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有