internal DataTable GetConformedResults(string spName, string fName, string lName) { DataTable dt = new DataTable(); SqlConnection con = new SqlConnection("Data Source=BUDDHIKA-PC\\SQLEXPRESS;Initial Catalog=VertualDoctor;Integrated Security=True"); con.Open(); SqlCommand SqlCmd = new SqlCommand(spName, con); SqlCmd.Parameters.Add("@vcFistName", DbType.String).Value = fName; SqlCmd.CommandType = CommandType.StoredProcedure; SqlCmd.Parameters.Add("@vcLastName", DbType.String).Value = lName; SqlCmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter DataAdp = new SqlDataAdapter(); DataAdp.SelectCommand = SqlCmd; DataSet result = new DataSet(); //Create a dataset DataAdp.Fill(result, "result"); //Fill the dataset dt = result.Tables["result"]; con.Close(); con.Dispose(); return dt; }
Sometimes you may get this error when you use transaction scope . The transaction is in doubt I also got this error recently and able to find the reason for it. That is because of the some of the readers had not properly disposed. Actually in this case you can use Using keyword to overcome this. Exception : System.Transactions.TransactionInDoubtException was unhandled by user code Message="The transaction is in doubt." Solution : using (reader) { }
Comments