Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MyClass
- {
- public int Id { get; set; }
- public string LongName { get; set; }
- }
- class Program
- {
- static void Main(string[] args)
- {
- var list = new List<MyClass>();
- var builder = new OracleConnectionStringBuilder();
- builder.Direct = true;
- builder.Sid = "VUZWORK";
- builder.UserId = "stud";
- builder.Password = "-----";
- builder.Server = "212.192.128.----";
- using (var connection = new OracleConnection(builder.ToString()))
- {
- connection.Open();
- using (var command = new OracleCommand("select count(*) from SDMS.O_USE_BASE_UNITS", connection))
- {
- var n = command.ExecuteScalar() as decimal?;
- Console.WriteLine($"{n}");
- command.CommandText = "SELECT UBU_ID AS \"Id\", NAME_LONG AS \"LongName\" FROM SDMS.O_USE_BASE_UNITS WHERE ROWNUM < 10";
- var reader = command.ExecuteReader();
- while (reader.Read())
- {
- list.Add(new MyClass { Id = reader.GetInt32(0), LongName = reader.GetString(1) });
- }
- }
- connection.Close();
- }
- foreach (var item in list)
- {
- Console.WriteLine($"{item.Id}\t{item.LongName}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement