可以的
用SqlCommandSqlCommand sqlCmd = new SqlCommand();sqlCmd.connection = ***;
sqlcmd.CommandText = "insert into test(name) values('value')";sqlCmd.ExecuteNoneQuery();
用SqlCommandSqlCommand sqlCmd = new SqlCommand();sqlCmd.connection = ***;
sqlcmd.CommandText = "insert into test(name) values('value')";sqlCmd.ExecuteNoneQuery();
SqlConnection conn=new SqlConnection(Common.DMSConfiguration.ConnectionString);
SqlDataAdapter dap=new SqlDataAdapter();
dap.SelectCommand=new SqlCommand();
SqlCommand comm=dap.InsertCommand;
comm.CommandText="insert sql";
comm.CommandType=CommandType.Text;
comm.Connection=conn;
conn.Open();
dap.SelectCommand.ExecuteNoneQuery();
conn.Close();
SqlConnection conn=new SqlConnection(你的连接串);
SqlCommand selectCommand=new SqlCommand("Select * From 你的表",conn);
SqlCommand insertCommand=new SqlCommand("你的Sql Insert语句",conn);SqlDataAdapter dap=new SqlDataAdapter(selectCommand);
dap.InsertCommand=insertCommand;
conn.Open(); //也可以不要这一句
dap.Update(你的数据集);
conn.Close(); //对应于conn.Open()
try
{
myCommand.ExecuteNonQuery();
}
SqlCommand insertCommand=new SqlCommand(yourInsertString,conn);
int intRet=insertCommand.ExecuteNonQuery();
最好看看msdn,上面有很详细的示例。