public static SqlServerConnect CreateSQL() { if (sqlServer == null) { sqlServer = new SqlServerConnect(); } return(sqlServer); }
private void Form1_Load(object sender, EventArgs e) { pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; SqlServerConnect sqlServer = SqlServerConnect.CreateSQL(); string lottoServerStr = ConfigurationManager.ConnectionStrings["Lotto"].ConnectionString; sqlServer.ServerOpen(lottoServerStr); SqlCommand com = new SqlCommand(); com.Connection = sqlServer.ServerOpen(lottoServerStr); com.CommandType = CommandType.StoredProcedure; com.CommandText = "SelectDB"; SqlDataReader dr = com.ExecuteReader(); while (dr.Read()) { WebToDB.dataLst.Add(new WebToDB(Int32.Parse(dr["DRWNO"].ToString()), Int32.Parse(dr["NO1"].ToString()), Int32.Parse(dr["NO2"].ToString()), Int32.Parse(dr["NO3"].ToString()), Int32.Parse(dr["NO4"].ToString()), Int32.Parse(dr["NO5"].ToString()), Int32.Parse(dr["NO6"].ToString()), Int32.Parse(dr["BONUSNO"].ToString()))); } dr.Close(); sqlServer.ServerClose(); //string constr = ConfigurationManager.ConnectionStrings["Lotto"].ConnectionString; //SqlConnection con = new SqlConnection(constr); //SqlCommand cmd = new SqlCommand(); //try //{ // con.Open(); // MessageBox.Show("성공"); // cmd.Connection = con; // cmd.CommandType = CommandType.Text; // cmd.CommandText = "select*from forlotto"; // var dr = cmd.ExecuteReader(); // while (dr.Read()) // { // MessageBox.Show(dr["NO1"].ToString()); // } //} //catch (Exception) //{ // MessageBox.Show("실패"); //} //con.Close(); }