sailing

Everything...

简单ADO.NET

        static void Main(string[] args)

        {

            using (SqlConnection connection = new SqlConnection(CSharpTest.Properties.Settings.Default.Database1ConnectionString))

            {

                SqlCommand sqlCommand = new SqlCommand();

                string sqlText = "select username from mytable where id=1";

                sqlCommand.CommandText = sqlText;

                sqlCommand.Connection = connection;

                connection.Open();

                string userNameDB = Convert.ToString(sqlCommand.ExecuteScalar());

                Console.WriteLine(userNameDB);

                sqlCommand.Dispose();

            }

        }

posted on 2007-03-12 02:33  乌生鱼汤  阅读(169)  评论(0编辑  收藏  举报

导航