Ver Mensaje Individual
  #3 (permalink)  
Antiguo 12/05/2009, 09:52
Avatar de thiancriss
thiancriss
 
Fecha de Ingreso: mayo-2009
Ubicación: Bogota
Mensajes: 29
Antigüedad: 15 años
Puntos: 0
Respuesta: Insert haciendo referencia a una tabla con otra relacionada

Aclaro soy novato en esto.


String Inserta_SQL;

Inserta_SQL = "INSERT INTO TB_AREA (AREAS_ID, DEP_ID, AREAS_NOMBRE)";
Inserta_SQL += "VALUES (" + Tb_Codigo_Area.Text + ","; //AREAS_ID int
Inserta_SQL += "'" + Tb_Nombre_Area.Text + "',"; //DEP_ID char(11)
Inserta_SQL += Cod_Dependencia + ")";

SqlDataAdapter Inserta_Emple = new SqlDataAdapter(Inserta_SQL, Conexion);
Inserta_Emple.InsertCommand = new SqlCommand(Inserta_SQL, Conexion);
Inserta_Emple.InsertCommand.CommandType = CommandType.Text;

Conexion.Open();

Inserta_Emple.InsertCommand.ExecuteNonQuery();

Conexion.Close();