using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace conect_sql
{
class Program
{
static void Main(string[] args)
{
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=sampledata;Integrated Security=True");
con.Open();
SqlCommand com = new SqlCommand("insert 用户名单(用户名,密码) values(@NewName,@NewID)", con);
com.Parameters.Add("@NewName",SqlDbType.NChar );
com.Parameters["@NewName"].Value = Console.ReadLine();
com.Parameters.Add("@NewID", SqlDbType.Int);
com.Parameters["@NewID"].Value = Console.ReadLine();
SqlDataReader re = com.ExecuteReader();
while (re.Read())
{
Console.WriteLine("\t{0}\t{1}", re[0], re[1]);
}
Console.Read();
}
}
}
沒有留言:
張貼留言