当前位置: 首页>>代码示例>>C#>>正文


C# Connection.CreateConnection方法代码示例

本文整理汇总了C#中DAL.Connection.CreateConnection方法的典型用法代码示例。如果您正苦于以下问题:C# Connection.CreateConnection方法的具体用法?C# Connection.CreateConnection怎么用?C# Connection.CreateConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DAL.Connection的用法示例。


在下文中一共展示了Connection.CreateConnection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: projectInfo

        public string[] projectInfo(string projectName)
        {
            Connection cs = new Connection();
            SqlConnection con = cs.CreateConnection();
            String[] info=new String[8];
            try
            {

                String quary = "select * from tbl_project where project='" + projectName + "'";
                SqlCommand cmd = new SqlCommand(quary, con);
                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    reader.Read();
                    for (int i = 0; i < 8; i++)
                    {
                        info[i] = reader[i].ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            con.Close();

            return info;
        }
开发者ID:,项目名称:,代码行数:28,代码来源:

示例2: createProjectTable

        public void createProjectTable(string tablename)
        {
            Connection cs = new Connection();
            SqlConnection con = cs.CreateConnection();

            try
            {
                String quary = "CREATE TABLE " + tablename +
                            "("
                            + "username varchar(255),"
                            + "name varchar(255),"
                            + "assaignedwork varchar(255),"
                            + "duedate varchar(255))";

                SqlCommand cmd = new SqlCommand(quary, con);
                cmd.ExecuteNonQuery();
                MessageBox.Show("Table Created");
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            con.Close();
        }
开发者ID:,项目名称:,代码行数:25,代码来源:

示例3: showingData

        public string[] showingData(string username,int flag)
        {
            Connection cs = new Connection();
            SqlConnection con = cs.CreateConnection();
            string query = "Select * from tbl_profile where name like '%" + username + "%'";
            SqlCommand com = new SqlCommand(query, con);

            SqlDataReader reader = com.ExecuteReader();
            for (int i = 1; reader.Read(); i++)
            {
                name[i] = reader[1].ToString();
                uname[i] = reader[0].ToString();
            }
            reader.Close();
            con.Close();
            if (flag == 1)
            {
                return name;
            }

            else
            {
                return uname;
            }
        }
开发者ID:,项目名称:,代码行数:25,代码来源:

示例4: showResult

        public string[,] showResult(string tablename)
        {
            Connection cs = new Connection();
            SqlConnection con = cs.CreateConnection();
            String[,] info = new String[100,5];
            try
            {

                String quary = "select * from "+tablename+"";
                SqlCommand cmd = new SqlCommand(quary, con);
                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    for (int i = 0; reader.Read();i++ )
                    {
                        info[i,0] = reader["username"].ToString();
                        info[i,1] = reader["name"].ToString();
                        info[i,2] = reader["assaignedwork"].ToString();
                        info[i,3] = reader["duedate"].ToString();
                        info[i,4] = reader["status"].ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            con.Close();

            return info;
        }
开发者ID:,项目名称:,代码行数:31,代码来源:

示例5: projectDisplay

        public string[] projectDisplay(string username)
        {
            Connection cs = new Connection();
            SqlConnection con = cs.CreateConnection();
            int counter=0;
            String[] info=new String[10];
            try
            {

                //1st Person
                String quary = "select * from tbl_project where people1username='" + username + "'";
                SqlCommand cmd = new SqlCommand(quary, con);
                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        info[counter++] = reader["project"].ToString();

                    }
                }

                //2nd person
                quary = "select * from tbl_project where people2username='" + username + "'";
                cmd = new SqlCommand(quary, con);
                using (SqlDataReader reader1 = cmd.ExecuteReader())
                {
                    while (reader1.Read())
                    {
                        info[counter++] = reader1["project"].ToString();
                    }
                }

                //3rd person
                quary = "select * from tbl_project where people3username='" + username + "'";
                cmd = new SqlCommand(quary, con);
                using (SqlDataReader reader2 = cmd.ExecuteReader())
                {
                    while (reader2.Read())
                    {
                        info[counter++] = reader2["project"].ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            con.Close();

               return info;
        }
开发者ID:,项目名称:,代码行数:52,代码来源:

示例6: noOfList

        public int noOfList(string tablename)
        {
            Connection cs = new Connection();
            SqlConnection con = cs.CreateConnection();

            int rows = 0;

            String query = "select * from " + tablename + "";
            SqlCommand cmd = new SqlCommand(query, con);
            SqlDataReader reader = cmd.ExecuteReader();
            DataTable dt = new DataTable();
            dt.Load(reader);
            rows = dt.Rows.Count;

            return rows;
        }
开发者ID:,项目名称:,代码行数:16,代码来源:

示例7: getInfo

        public string[] getInfo(string projectname)
        {
            Connection cs = new Connection();
            SqlConnection con = cs.CreateConnection();
            String[] info=new String[8];
            String quary;
            SqlCommand com;

            try
            {

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
开发者ID:,项目名称:,代码行数:17,代码来源:

示例8: editPassword

        public void editPassword(string username, string password)
        {
            Connection cs = new Connection();
            SqlConnection con = cs.CreateConnection();

            try
            {
                String query = "UPDATE tbl_authenticate SET password='" + password +  "'where username='" + username + "'";

                SqlCommand cmd = new SqlCommand(query, con);
                cmd.ExecuteNonQuery();

                con.Close();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
开发者ID:,项目名称:,代码行数:20,代码来源:

示例9: updateProject

        public void updateProject(string name, string description, string user1, string name1, string user2, string name2, string user3, string name3, string projectname)
        {
            Connection cs = new Connection();
            SqlConnection con = cs.CreateConnection();

            try
            {
                String query = "UPDATE tbl_project SET project='" + name + "',projectdescription='" + description + "',people1username='" + user1 + "',people1name='" + name1 + "',people2username='" + user2 + "',people2name='" + name2 + "',people3username='" + user3 + "',people3name='" + name3 + "'where project='" + projectname + "'";

                SqlCommand cmd = new SqlCommand(query, con);
                cmd.ExecuteNonQuery();

               // MessageBox.Show(name+" "+description+" "+user1+" "+name1+" "+user2+" "+name2+" "+user3+" "+name3+" Edited!!!!");
                con.Close();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
开发者ID:,项目名称:,代码行数:21,代码来源:

示例10: LoginConnection

        public Boolean LoginConnection(string userName, string password)
        {
            Connection cs = new Connection();
            SqlConnection con = cs.CreateConnection();

            int rows = 0;
            string uName = userName;
            string pass = password;

            String query = "select * from tbl_authenticate where username='" + uName + "' and password='" + pass + "'";
            SqlCommand cmd = new SqlCommand(query, con);
            SqlDataReader reader = cmd.ExecuteReader();
            DataTable dt = new DataTable();
            dt.Load(reader);
            rows = dt.Rows.Count;

            if (rows > 0)
                return true;
            else
                return false;
        }
开发者ID:,项目名称:,代码行数:21,代码来源:

示例11: editInfo

        public string editInfo(string username, string name,  string designation, string email, string phoneno, string address,string dob,string gender)
        {
            Connection cs = new Connection();
            SqlConnection con = cs.CreateConnection();

            try
            {
                String query = "UPDATE tbl_profile SET name='" + name + "',username='" + username + "',designation='" + designation + "',email='" + email + "',phoneno='" + phoneno + "',address='" + address + "',dateofbirth='" + dob + "',gender='" + gender + "'where username='" + username + "'";

                SqlCommand cmd = new SqlCommand(query, con);
                cmd.ExecuteNonQuery();

                con.Close();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return username;
        }
开发者ID:,项目名称:,代码行数:21,代码来源:

示例12: addToDo

        public void addToDo(string username, string name, string todo, string date, string table)
        {
            Connection cs = new Connection();
            SqlConnection con = cs.CreateConnection();

            try
            {

                String query = "INSERT INTO "+table+" VALUES('" + username + "','" + name + "','" + todo + "','" + date + "','" + "false" +  "')";

                SqlCommand cmd = new SqlCommand(query, con);
                cmd.ExecuteNonQuery();
                MessageBox.Show("Assaigned Work Added!!!");
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            con.Close();
        }
开发者ID:,项目名称:,代码行数:22,代码来源:

示例13: updateTable

        public void updateTable(string oldname, string newname)
        {
            Connection cs = new Connection();
            SqlConnection con = cs.CreateConnection();

            //try
            //{
            String query = "sp_rename '" + oldname +
                    "','" + newname + "'";

                SqlCommand cmd = new SqlCommand(query, con);
                cmd.ExecuteNonQuery();

                MessageBox.Show(oldname + " "+" Edited");
                con.Close();
            //}

            //catch (Exception ex)
            //{
                //MessageBox.Show(ex.Message);
            //}
        }
开发者ID:,项目名称:,代码行数:22,代码来源:

示例14: projectAdd

        public void projectAdd(string projecttitle,string description,string uname1,string name1,string uname2,string name2, string uname3,string name3)
        {
            Connection cs = new Connection();
            SqlConnection con = cs.CreateConnection();

            try
            {

                String query = "INSERT INTO tbl_project VALUES('" + projecttitle + "','" +description + "','" + uname1 + "','" +name1 + "','" + uname2 + "','" +name2 + "','" + uname3 + "','" + name3 + "')";

                SqlCommand cmd = new SqlCommand(query, con);
                cmd.ExecuteNonQuery();
                MessageBox.Show("Project Added!!!");
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            con.Close();
        }
开发者ID:,项目名称:,代码行数:22,代码来源:

示例15: nameCheck

        public int nameCheck(string name)
        {
            int rows = 0;

            Connection cs = new Connection();
            SqlConnection con = cs.CreateConnection();

            try
            {
                string query = "Select * from tbl_profile where name like '%" + name + "%'";
                SqlCommand cmd = new SqlCommand(query, con);
                SqlDataReader reader = cmd.ExecuteReader();
                DataTable dt = new DataTable();
                dt.Load(reader);
                rows = dt.Rows.Count;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            return rows;
        }
开发者ID:,项目名称:,代码行数:22,代码来源:


注:本文中的DAL.Connection.CreateConnection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。