using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.SqlClient; namespace AccessDb { class Program { static void Main(string[] args) { String connectionStr = @"server=ip;database=daqing2_91_hd_Info;uid=sa;pwd=密码"; SqlConnection connection = new SqlConnection(connectionStr); connection.Open(); String SQLCOMMAND = "SELECT * FROM BeautyInfo"; SqlCommand command = new SqlCommand(SQLCOMMAND, connection); SqlDataReader reader = command.ExecuteReader(); int colNum = reader.FieldCount; while (reader.Read()) { for (int i = 0; i < colNum; i++) { Console.WriteLine(reader[i]); } } if (connection != null) { connection.Close(); } Console.ReadLine(); } } }
c#数据库简单操作
最新推荐文章于 2018-11-04 17:06:14 发布