using System; using System.Data; using System.Data.SqlClient; namespace ConsoleApplication2 { public class Program { public static void Main(string[] args) { SqlConnection conn = new SqlConnection(); conn.ConnectionString = "server=.;database=Database;uid=sa;pwd=******"; conn.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "INSERT INTO dbo.Records( CorpName, VisitTime ) VALUES ( @CorpName,@VisitTime)"; cmd.Parameters.Add("@CorpName", SqlDbType.NVarChar).Value = "冲致分公司"; cmd.Parameters.Add("@VisitTime",SqlDbType.DateTime).Value=DateTime.Now; cmd.ExecuteNonQuery(); } } }