You must Sign In to post a response.
  • Category: ASP.NET

    Asp.net Sql server connection issue.

    Any idea on the below Issue, I am facing this issue while filling the dataset.

    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) at Guidepost.Data.GUDataHelper.ExecuteDataset(SqlConnection connection, CommandType commandType, String commandText, SqlParameter[] commandParameters) at Guidepost.Data.GUDataHelper.ExecuteDataset(String connectionString, CommandType commandType, String commandText, SqlParameter[] commandParameters) at Guidepost.BLL.GTS.GetGTSIDetails(String caseNum, String team, String investigator) at GTSI_GTSI.BindGTSIGrid() at GTSI_GTSI.Page_Load(Object sender, EventArgs e
  • #762244
    Hi
    Can you share your code .

    I have mention code for sample code for connection
    C# to sql server this is helpful to you

    Step1-> Namespace


    using System.Data;
    using System.Data.SqlClient;


    Step2-Initial Connection String


    //Windows authentication
    SqlConnection sqlcon = new SqlConnection("Data Source=PCNAME;Initial Catalog=DBNAME;Integrated Security=True;MultipleActiveResultSets=True;");

    //Sql server authentication - Need user id pwd include your connection string
    SqlConnection sqlcon = new SqlConnection("Data Source=PCNAME;Initial Catalog=DBNAME;Integrated Security=True;MultipleActiveResultSets=True;");

    //Fetch the connectionstring from webconfig file.
    string s = ConfigurationManager.AppSettings["Connectionstring"].ToString();


    Step3 -> Get Datatable


    adapter = new SqlDataAdapter("Select Query", con);
    adapter.Fill(table);

    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #762245
    Thanks for reply

    This is my code, Its working fine for past 2 years , suddenly I am facing an issue in Production.

    ds = objGTSI.GetGTSIDetails(Param1, Parm2, Param);

    public DataSet GetGTSIDetails(string Param1,string Param2, string Param3)
    {
    DataSet ds = null;
    try
    {
    SqlParameter [] aParams= new SqlParameter[3];

    aParams[0] = new SqlParameter("@Param1", SqlDbType.VarChar, 20);
    aParams[0].Value = Param1;

    aParams[1] = new SqlParameter("@Param2", SqlDbType.VarChar, 20);
    aParams[1] .Value = Param2;

    aParams[2] = new SqlParameter("@Param3", SqlDbType.VarChar, 20);
    aParams[2].Value = Param3;

    ds = GUDataHelper.ExecuteDataset(ConnString, CommandType.StoredProcedure,
    "dbo.StoredProcedure", aParams);
    }
    catch (Exception ex)
    {

    throw;
    }

    return ds;

    }

  • #762246
    Hi

    Do one things keep this things

    1.Trace step by step in your code.

    2. Fields are correct or not check them

    3.Procedure parameter are correct or not then you passing data type and receiving side check correct or not

    You have mention this method GetGTSIDetails

    But i do know what do you wrote here so check your self best trace where you meet this issue post snapshot

    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #762253
    Hello Geetha,

    Web. Config :

    <connectionStrings>
    <add name="MyCon" providerName="MySql.Data.MySqlClient" connectionString="server=127.0.0.1;User Id=hardik;password=Pass@1234;Persist Security Info=True;database=Employee;port=3306"/>
    </connectionStrings>


    Page Level Code :

    using System.Data;
    using MySql.Data.MySqlClient;
    using System.Configuration;

    string constrng = ConfigurationManager.ConnectionStrings("MyCon").ToString();

    protected void Page_Load(object sender, EventArgs e)
    {
    MySqlConnection con = new MySqlConnection(constrng);
    if (string.IsNullOrEmpty(Session["User_Name"]) && string.IsNullOrEmpty(Session["User_Pass"])) {
    OrdersGridView.DataSource = null;
    Response.Redirect("~/UserAccess/Login.aspx");
    } else {
    con.Open();
    MySqlCommand cmd = new MySqlCommand("SELECT om.Order_ID, om.Order_Date, od.Item_ID, im.Item_Name, im.Item_Category, od.Item_Rate, od.Item_Qty, od.Item_Amount FROM ordermaster om INNER JOIN orderdetail od ON om.Order_ID = od.Order_ID INNER JOIN itemmaster im ON od.Item_ID = im.Item_ID WHERE om.Cust_ID = '" + Session["User_Name"] + "' ORDER BY om.ID Desc LIMIT 5", con);
    MySqlDataAdapter adp = new MySqlDataAdapter(cmd);
    DataSet ds = new DataSet();
    adp.Fill(ds);
    OrdersGridView.DataSource = ds;
    OrdersGridView.DataBind();
    }
    }


    Hope this will help you.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"

  • #762262
    Hi geetha,

    As you mentioned, this is working fine from past 2 years onwards... suddenly you get this problem, what you have to load recently, any web config file movement and any movements happen..? Please check those changes again, and as you post in the thread that is stack trace details, I request you to please share error details too, to find the root cast problem of this.

    Please recheck this method once, GetGTSIDetails
    and check the datatypes of parameters etc...

    Before go with other activities, first check the recent changes which you moved to production, and recheck those changes. I guess if you follow this, issue will clear.

    Hope this will helpful to you...

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #762560
    Hi

    Instead of posting the entire error message you can post what actually the error is? That is good.

    check you database connections and check whether dataset is filling or not.

    Regards

    Sai Krishna Reddy.


Sign In to post your comments