|
When I used CR spit, 15 years ago I would prepare the dataset in code and use a local reportviewer (not connected to the database) and pass the prepared data to the viewer, it was a PITA while creating the report but made deployment and management easier. I gave up CR when their support took 15 months to reply to a support ticket.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
public List<T> DatasettoList<T>(string commandText, CommandType commandType, IDbDataParameter[] parameters = null) where T : class, new()
{
DataSet dataSet = new DataSet();
if ((commandType == null) || (commandText == null) || (commandText.Length == 0))
{
throw new Exception("Invailid command");
}
dataSet = GetDataSet(commandText, commandType, parameters);
if (dataSet.Tables.Count == 0)
{
return null;
}
if (dataSet.Tables[0].Rows.Count == 0)
{
return null;
}
ProposalDownloadView prop = new ProposalDownloadView();
List<ProposalDownloadView> proplist = new List<ProposalDownloadView>();
List<T> list = new List<T>();
var myData = dataSet.Tables[0].AsEnumerable().Select(r => new
{
UserId = r.Field<string>("UserId"),
UseProposalNorId = r.Field<int>("UseProposalNorId"),
FromDate = r.Field<decimal?>("FromDate"),
ToDate = r.Field<decimal?>("ToDate")
}).ToList();
list = myData.ToList();
return list;
}
I am unbale to return list after above code third list line creates error. Please help. Thanks in advance
|
|
|
|
|
You forgot to tell us what the error is.
But in this case, it's pretty obvious: you have a List<> of an anonymous type. Calling .ToList() on that will return exactly the same thing - a list of your anonymous type. You cannot magically treat that as a list of T .
It looks like you've copied a couple of different code samples from somewhere and tried to mash them together without understanding what they're doing.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I’m making a windows form project, I made a method to play a music and I put that method in form1 so when the game starts it can play the music but I have other sounds effects in the game also so when I hit space for shooting it cuts the background music that is playing and stays just the sound of shooting or explosions sounds but the music never gets to play again until I restart the game.
What should I do for when the music keeps playing it also makes the shooting and explosion sounds
|
|
|
|
|
How would we know, without any idea what your code is doing?
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with - we get no other context for your project.
Imagine this: you go for a drive in the country, but you have a problem with the car. You call the garage, say "it broke" and turn off your phone. How long will you be waiting before the garage arrives with the right bits and tools to fix the car given they don't know what make or model it is, who you are, what happened when it all went wrong, or even where you are?
That's what you've done here. So stop typing as little as possible and try explaining things to people who have no way to access your project!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
If you are using MediaPlayer, you will be pleased to know that it doesn't need to be dispatched onto the main thread. What you could do is have separate threads for your music and your sound effect. When the sound effect needs to play, you would signal it and it would play on the other thread. This should result in both of your sounds playing together.
|
|
|
|
|
The below code works EXCEPT for one issue: the updated string has the following value in front of it: "System.Windows.Forms.TextBox,Text:"
Why is that there and how to be rid of it? The name of the field is masterRec. Code snippets follow:
FORM1 (main code) & FORM2 are the names I give them for purposes of this post and not their operating names. Don't think I am actually using the Get/Set apparatus.
FORM1 (In part):
FormUpdate fu = new FormUpdate(hotRec); // INSTANTIATE UPDATE FORM CLASS
fu.action = "UP"; // FormUpdate Action = UPDATE
fu.masterRec = hotRec; // Set local Master Record in FormUpdate
this.Visible = false; // Turn off visibility for this form
fu.ShowDialog(); // <-------------------------- THIS IS WHERE THE OTHER FORM EXECUTES!!!
this.Visible=true; // Turn on visibility for this form[/code]
FORM2 (In total):
namespace TestDictionary
{
public partial class FormUpdate : Form
{
// V A R S
public string masterRec { get; set; }
public string action { get; set; }
private string siteId, logonID, pw, date, comments;
// public FormUpdate()
public FormUpdate(String myMaster)
{
InitializeComponent();
}
private void FormUpdate_Load(object sender, EventArgs e) // F O R M L O A D E D
{
// Disassemble the Master Record into its component fields to be displayed in this form
if (action == "UP")
{
string[] tokens = masterRec.Split(',');
siteId = tokens[0];
logonID = tokens[1];
pw = tokens[2];
date = tokens[3];
comments = tokens[4];
websiteTextBox.Text = siteId;
logonIDTextBox.Text = logonID;
pwTextBox.Text = pw;
dateTextBox.Text = date;
commentsTextBox.Text = comments;
}
}
private void Perform_Click(object sender, EventArgs e) // P E R F O R M B U T T O N (AFTER UPDATES)
{
if (action == "UP") // If Update, return updated Master (REASSEMBLED)
masterRec = websiteTextBox + "," + logonIDTextBox.Text + "," + pwTextBox.Text + "," + dateTextBox.Text + "," + commentsTextBox.Text + ",";
this.Close();
}
}
}
THANK YOU FOR ANY HELP!
|
|
|
|
|
Assuming that websiteTextBox is an instance of a TextBox , then doing this:
masterRec = websiteTextBox + "," + logonIDTextBox.Text; will call the default ToString implementation on it. Since TextBox does not implement ToString itself, you get the object.ToString version which returns the string name of the class, not it's content.
So if logonIDTextBox.Text contains "Text", you string will end up as "System.Windows.Forms.TextBox,Text" as you see.
You could use the Text property instead of the instance?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I have 2 projects in 1 solution. Where one of the project is included with a database manager class.
Projects
Then the second project is included with another class which have all properties of the form. That class is called Diseases class. I want store different types of diseases. Here I set the options of the input like only numbers or can't leave empty and so on.
Properties
I would to insert data from the form throw the properties class but can't see the properties class. I have a following error message:
Methods
The type or namespace name 'Diseases' could not be found (are you missing a using directive or an assembly reference?)
I'm lost. Anybody can help me please what I doing wrong?
|
|
|
|
|
Projects within a Solution are independant: they cannot "see" each other unless you do two things:
1) Add a reference in Project A to project B: in your case you would want to Project reference added to your "Projects" project which references the "Properties" project.
2) Add a using statement in each .CS file of project A that includes project B: in your case that would be
using Properties;
But please, change your project / namespace names: make them descriptive of what they contain, or what they are used for: "Properties" and "Projects" are both descriptions which are already used in connection with C# so they add to the confusion rather than make it clearer!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I'm working on a WPF app that uses conditional compiler symbols all over the place. Then, some bright spark decided that the best way to test all of these was to create a new project for each one that references all the same classes/files/view/viewmodels, etc, but with a different compiler symbol in the debug settings.
- The #IF symbols are ALL OVER THE CODE. It's a mess.
- There are multiple project files that simply exist to compile different logic paths based on the symbol.
This all seems like a hack. Anyone have a better approach?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
A more important question is : why does it need all these conditional compilations?
To test them properly, you are going to need to have a new project for every possible combination, not just every symbol ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
That's my point. I think they were trying to create different versions of the app.
There's got to be a better way
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Disk space is cheap. RAM space is cheap. Simple IF-statements are cheap.
OK, so changing the conditional compilation to run time tests could increase CPU load by half a percent. In extreme cases, the level of accusations of 'software bloat' may rise by as much as ten percent.
Still, I think that is a better way.
|
|
|
|
|
Have a look at this question: Extend base project to dedicated customer projects[^] - it's another guy with a similar problem, and trying to work out a solution.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
We are calling 2 methods using TPL
both methods return similar data type <string>
Task.WhenAll returns a string array.
What is the best place to await.
Line 3 pattern
or
Line 4 + 5 pattern
or
Line 6 + 7 pattern
What is the reason for choosing one over the other pattern?
Appreciate any help.
==================================
1. Task<string> t1 = SomeMethod_A_ToCallStoredProcedure();
2. Task<string> t2 = SomeMethod_B_ToCallStoredProcedure();;
3. string[] X = await Task.WhenAll(t1,t2);
4. string[] X = Task.WhenAll(t1,t2)
5. await X;
6. string[] X = Task.WhenAll(t1,t2)
7. X.wait;
|
|
|
|
|
Try doing your own homework assignment. If you'd tried, you'd see that only one of those options will compile.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Windows Forms project. Panel is 1800 x 900 with a background image. Why is the image dark? I tried other images and they display correctly. I played around with settings and no luck. The second image is the original.
Pics shown here
Thanks
Thanks
|
|
|
|
|
Does it happen on other PC's? .png; what happens if you use .bmp?
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Good afternoon,
I am not sure what the issue is, I have written this piece of code, rewritten it and looked up on the net at various sites for guidance and not sure what is wrong with it.
I am taking a table from a database and placing it in memory, which works fine. But, now I am attempting to read the 40Percent field column searching to find the row thats just less than a certain value, but getting an error.
public DataSet ExecuteQuery()
{
DataTable table = ds.Tables["Fill_Data"];
string expression;
expression = "40Percent = 0.355";
DataRow[] foundRows;
foundRows = table.Select(expression);
for (int i = 0; i < foundRows.Length; i++)
{
Console.WriteLine(foundRows[i][0]);
}
return ds;
}
[Image of error message]
Richard
Disable Vet
Grandfather
Pain in the @ss
|
|
|
|
|
At a guess I think the parser sees the word Percent as an operator rather than part of the column name, try renaming the column.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Good morning,
Actually Kelly in the next message had it figured out. It was the number that started the table name that was causing all the issues. As soon as I placed brackets around it, it functioned as expected.
But, I then went in and removed all the number at the beginning of the table names and wrote them out. "40Percent" became "FortyPercent".
Thanks for the help.
Richard
Disable Vet
Grandfather
Pain in the @ss
|
|
|
|
|
Ah well I was close - glad you got it sorted.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
Have you tried putting [] (square brackets) around the 40Percent?
expression = "[40Percent] = 0.355";
The reason I mention that is because as an example in SQL Server you can't have a number at the beginning of a field name, or any object name for that matter. So you have to enclose the name with square brackets.
Kelly Herald
Software Developer
|
|
|
|
|
Good morning and Thank you.
You were correct. As soon as I placed brackets around the "40Percent", it functioned as expected. But, I went ahead and renamed the tables and its now "FortyPercent" and it is still function as previously.
Thank you for your assistance.
Richard
Disable Vet
Grandfather
Pain in the @ss
|
|
|
|