Quantcast
Channel: Visual COBOL - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4356

.Net Cobol SqlDataReader

$
0
0

This is just sample code, but I wanted to know what would be the equivalent .net cobol to the while(dr.read) and populate to a list.

 

publicclassStudent{publicint ID {get;set;}publicstringName{get;set;}publicDateTimeDateOfBirth{get;set;}}
after that
            List<Student> student =newList<Student>();SqlConnection conn =newSqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=D:\Prac\TestAssembly\ForumsProjectCSharp\App_Data\Studetnt.mdf;Integrated Security=True;User Instance=True");SqlCommand cmd =newSqlCommand("select * from Student", conn);SqlDataReader dr;try{
                conn.Open();
                dr = cmd.ExecuteReader();while(dr.Read()){
                    student.Add(newStudent(){
                        ID = dr.GetInt32(dr.GetOrdinal("ID")),Name= dr.GetString(dr.GetOrdinal("Name")),DateOfBirth= dr.GetDateTime(dr.GetOrdinal("DateOfBirth"))});}
                dr.Close();}catch(Exception exp){throw;}

Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>