You could support me I'm new, I'm migrating data from Oracle to SQL server but the problem is that I'm trying to insert data and everything was fine, until I came up with the following: When inserting the data there are null fields and I do not know how to correct it.
** Error managerid there I have the null fields. managerid = reader3.GetInt32 (2);
It tells me there is no data and it causes error. **
//INSERT DEPARTMENTS
cmd2.CommandText = "SELECT * FROM DEPARTMENTS";
cmd2.Connection = conectar;
cmd2.CommandType = CommandType.Text;
SqlCommand insert3 = conectarsql.CreateCommand();
insert.CommandType = CommandType.Text;
int departmentid;
string departmentname;
int managerid;
int locationid;
OracleDataReader reader3 = cmd2.ExecuteReader();
reader = cmd2.ExecuteReader();
while (reader3.Read())
{
departmentid = reader3.GetInt32(0);
departmentname = reader3.GetString(1);
managerid = reader3.GetInt32(2);
locationid = reader3.GetInt32(3);
insert.CommandText = "INSERT INTO DEPARTMENTS VALUES('" + departmentid + "','" + departmentname + "','" + managerid + "'," + locationid + ")";
insert.ExecuteNonQuery();
//FIN INSERT DEPARTMENTS