Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this is my code, and when I view it on my browser the return page comes back blank

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

public partial class Default2 : System.Web.UI.Page
{

    public string strconnString { get; set; }private string strConnString = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DataBind();

            string strQuery = "select Reader_name, book_name,book_author,borrow_date,expected return_date" + "from readers Query";
            SqlCommand cmd = new SqlCommand(strQuery);
            GridView1.DataSource = GetData(cmd);
            GridView1.DataBind();
        }
    }
    protected void EditReader(object sender, GridViewEditEventArgs e)
    {

        GridView1.EditIndex = e.NewEditIndex;

        DataBind();

    }
    protected void CancelEdit(object sender, GridViewCancelEditEventArgs e)
    {
        GridView1.EditIndex = -1;
        DataBind();
    }


    protected void UpdateReader(object sender, GridViewUpdateReaderEventArgs e)
    {
        string Readername = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtReadername")).Text;
        string Bookname = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtbookname")).Text;
        string Bookauthor = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtBokkauthor")).Text;
        string BorrowDate = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtBorrowdate")).Text;
        string ExpectedreturnDate = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtexpectedreturndate")).Text;
        SqlConnection con = new SqlConnection(strconnString);
        SqlCommand cmd = new SqlCommand();

        cmd.CommandType = CommandType.Text;
        cmd.CommandText = "update Reader name=@Reader name," + "Book name=@Book name," + "Book author=@Book author, " + " Borrow date=@Borrow date ," + " expected return date=@expected return date where Reader name=@reader name;" +
            "select Reader name,Book name,Book author,Borrow date,expected return date from Query table";

        cmd.Parameters.Add("@Readername", SqlDbType.VarChar).Value = Readername;
        cmd.Parameters.Add("@Bookname", SqlDbType.VarChar).Value = Bookname;
        cmd.Parameters.Add("@Bookauthor", SqlDbType.VarChar).Value = Bookauthor;
        cmd.Parameters.Add("@BorrowDate", SqlDbType.VarChar).Value = BorrowDate;
        cmd.Parameters.Add("@ExpectedreturnDate", SqlDbType.VarChar).Value = ExpectedreturnDate;

        GridView1.EditIndex = -1;

        GridView1.DataSource = GetData(cmd);

        GridView1.DataBind();


   
    protected void DeleteReader(object sender, EventArgs e)
    {
        LinkButton lnkRemove = (LinkButton)sender;
        SqlConnection con = new SqlConnection(strConnString);
        SqlCommand cmd = new SqlCommand();
        cmd.CommandType = CommandType.Text;
        cmd.CommandText = "delete from readers Query  where " + "Readerame=@Readername;" + "select Reader name,Book name,Book author,Borrow date,expected return date from reader Query";
        cmd.Parameters.Add("@Readername", SqlDbType.VarChar).Value = lnkRemove.CommandArgument;
        GridView1.DataSource = GetData(cmd);
        GridView1.DataBind();


  
    }
}
Posted
Updated 16-Mar-15 2:11am
v2
Comments
CHill60 16-Mar-15 8:14am    
Looks like the sql query is wrong - should be string strQuery = "select Reader_name, book_name,book_author,borrow_date,expected return_date from readers Query";

1 solution

C#
throw new NotImplementedException;
Is not an error: it's teh system telling you that you forgot to add code to actually make a method do what you wanted it to do!

When you use Visual Studio to "fill in the blanks" and create a method for you, the template it creates contains only that one line - so that when you run your code in development you are forcibly reminded that your code will not work correctly because you haven't written it yet! :laugh:

So look in your code, find the method(s) that you haven't written yet - and write them...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900