Exemplo n.º 1
0
        public RoadGuide GetRoadByID(string Road_ID)
        {
            using (SqlConnection sqlConn = new SqlConnection(connectionString))
            {
                using (SqlCommand sqlCmd = sqlConn.CreateCommand())
                {
                    sqlCmd.CommandText = "Select * from Road where Road_ID = @Road_ID";
                    sqlCmd.Parameters.AddWithValue("@Road_ID", Road_ID);

                    RoadGuide roads = new RoadGuide();
                    sqlConn.Open();

                    using (SqlDataReader sqlDR = sqlCmd.ExecuteReader())
                    {
                        while (sqlDR.Read())
                            roads = GetRoadGuideInfo(sqlDR);

                        if (sqlDR != null)
                            sqlDR.Close();
                    }
                    return roads;
                }
            }
        }
Exemplo n.º 2
0
        public RoadGuide GetRoadGuideInfo(SqlDataReader sqlDR)
        {
            RoadGuide row = new RoadGuide();

            row.Road_ID = (sqlDR["Road_ID"]).ToString();
            row.Name = (sqlDR["Name"]).ToString();
            row.Code = (sqlDR["Code"]).ToString();
            row.Mnemocode = (sqlDR["Mnemocode"]).ToString();

            return row;
        }