2
Answers

Problem in edmx file in mvc.net

krishna kishore

krishna kishore

10y
1.1k
1
Dear Team,
i am developing an application in MVC.net 4.5 framework, and i have created a database with stored procedures, now i am trying to add an edmx(ado.net entity model) and i have choosen both the tables and stored procedures. and their is one sp which retuens 5 tables(qualification, gender,blood group etc)
and the edmx file has to create a seperate class for each table  in the model , but it is creating a class only for first tablequalification, though i called the sp from the method(linq calling type) it is returning one one table object. i am not able to get the rest table classes.
please help me to resolve the issue.
 
Thanks and regards
j krishna kshore
Answers (2)
0
Ken Barrett

Ken Barrett

NA 173 0 15y
Looks as if I figured it out.  It may not be the most elegant solution, but it seems to work.. and I understand it.

By number of entries  I meant that the number of entries that are in the guest book are variable. This depends on how many people have signed it.  So the number of entries that are shown on the view guest book page depends on how many people have signed the guest book.

The way I solved this was first to include a html span on the web page. As in :
<!-- start guest book entries -->
<span id="GBentries" runat=server></span>


Then I used a data reader (I like data readers because I'm old fashioned) to load only the date, name, and comments out of the data table. There's a lot more data in there, but I only want to display these items.  As in :
  private int getGBentries() {
    int rows = 0 ;
    string cmd = "SELECT Date, Name, Comments FROM dbo.Guest" ;
    using (SqlConnection gconn = new SqlConnection(dbConn))
    {
      try {
        gconn.Open() ;
        SqlCommand Scmd = new SqlCommand(cmd, gconn);
        SqlDataReader dr = Scmd.ExecuteReader() ;
        while(dr.Read()) {
          GuestEntry ge = new GuestEntry((DateTime)dr["Date"],
                            (string)dr["Name"],(string)dr["Comments"]) ;
          entries.Push(ge) ; // build a stack to be used later
          rows++ ;
        }
        dr.Close() ;
        gconn.Close() ;
        return(rows) ;
      } catch {
        return(0) ;
      }
    }
  }


As each item was read in a string object was appended with a new html table to hold that particular entry.  As in :
  private void buildEntries() {
    foreach (GuestEntry ge in entries) {
      guestOut +=
        "<table width=800 cellpadding=8>\n" +
        "  <tr><td colspan=2><hr /></td></tr>\n" +
        "  <tr>\n" +
        "    <td width=200>Date</td>\n" +
        "    <td width=600>" + ge.getCommentDate().Date + "</td>\n" +
        "  </tr>\n" +
        "  <tr>\n" +
        "    <td width=200>Name</td>\n" +
        "    <td width=600>" + ge.getName() + "</td>\n" +
        "  </tr>\n" +
        "  <tr>\n" +
        "    <td width=200>Comments</td>\n" +
        "    <td width=600>" + ge.getComment() + "</td>\n" +
        "  </tr>\n" +
        "</table>\n" ;
    }
  }


Then the string was written out to the span id on the web page. As in :
  protected void Page_Load(object sender, EventArgs e) {
    getGBentries() ;
    buildEntries() ;
    GBentries.InnerHtml = guestOut ;
  }

0
Roei Bar

Roei Bar

NA 7.8k 0 15y
by saying number of entries, do you want the number of entries in the Guestbook or the number of entries to that page?

the number of entries in the guestbook is easy, use databindNavigator it will give you all the data you return for you to manipulate and also you can know how many entries or more truly to say how many rows you have...

for number of entries to page you need  a counter control that you can download all over