|
You are getting an error when calling a function, but you haven't shown the C/C++ prototype from the header file or your C# declaration of this function.
As far as the struct goes, try passing StringBuilder s for the first two parameters that are initialized with a suitable capacity.
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Okay, I'm still fairly new to the whole c# coding world so please don't beat me up too bad.
I was wondering if someone could shed some light on me with how I would go about doing the following..
I have a database setup to keep track of my books and I wanted to make a treeview to list the authors and then each book that I have by that author. Well lets say I have 4 books for the example
Database consist of ID, Author, Title
row 1 : 1, Tony Stegall, First book
row 2 : 2, Joe Smith, Joe Says Hi
row 3 : 3, Tony Stegall, Second book
row 4 : 4, Jim Smith, Jim has a friend named Joe
How in the heck can i get it to print out something like this
Smith,Jim
- Jim has a friend named Joe
Smith,Joe
- Joe Says Hi
Stegall, Tony
- First Book
- Second Book
Would I have to run a filter on each authorname? Or is there some other way to do this? Just trying to learn this stuff but not really sure how to go about it. I pretty much understand the whole treeview add a parent then add a child deal but I'm not sure how to get the childs to be placed under the unique parent...
Thanks for your help.
|
|
|
|
|
|
Thanks for your fast reply. I didn't go with multiple tables. I definitely should have but being it is a small simple database I didn't take the time to setup relationships. Anyway, for anyone interested in how to do this if your beginning like I am then based on the links provided I wrote the following to get a Unique Author First and LastName and also Get the titles grouped by the unique author.
#region Make tree view
private void PopulateTreeView1()
{
bookdbDataSet Dataset = bookdbDataSet;
bookListTableAdapter.Fill(Dataset.BookList);
bookdbDataSet uAuthor = bookdbDataSet;
bookListTableAdapter.FillBydauthor(uAuthor.BookList);
TreeNode rootNode = treeView1.Nodes.Add("Authors");
rootNode.ImageIndex =0 ;
foreach (DataRow Row in uAuthor.Tables[0].Rows)
{
TreeNode tn = new TreeNode(Row["AuthorLast"].ToString()+','+Row["AuthorFirst"].ToString());
foreach (DataRow Child in uAuthor.Tables[0].Rows)
{
tn.Nodes.Add(Child["Title"].ToString());
}
treeView1.Nodes.Add(tn);
}
}
#endregion
|
|
|
|
|
Well, I can't dig deeper to your code for now
but you can set a dataset parent-child relationship in a single table also.
|
|
|
|
|
Hmm, I got the code to work for the unique authors but I can't figure out how to populate the child nodes as I run through the dataset. I only have one table in the database so I don't think relationship would apply in my case... Where I'm confused is how do you refill a dataset based off the results of another fill..
Basically I'm wanting to fill dataset by unique author
then while the dataset is on the first author row I want to then fill the dataset based on his/her name.
and run a foreach to get all the books associated with that author. I understand that I am updating the tableadapter collection inside a foreach and it is a no no but I can't figure out how i would code this. I know it's probably not the best of design but I am still in the toddler stages of this so...
here is my code thanks
http://csharp.pastebin.com/m58597462
the second foreach is where it borks during run-time
|
|
|
|
|
Hi.
I wish to create a ASP.NET server control with design-time capabilities.
But i want to display, when designing and when rendering to a browser, some HTML code in the top which you can't edit.
How do i accomplish this?
Programming is like Mathematics… you take ONE step at the time!
|
|
|
|
|
|
The control is devoloped in C#. Which forum should i use insted?
I've searched, looked in MSDN, but can't find info or a example which covers my problem.
Programming is like Mathematics… you take ONE step at the time!
|
|
|
|
|
You are asking for an ASP.NET server control, maybe the ASP.NET forum would be the place to ask.
[DK]KiloDunse wrote: I've searched, looked in MSDN, but can't find info or a example which covers my problem
Then you haven't searched very well. No, I'm not going to do it for you either, the information is very easy to find. Try again.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
|
|
hi
I am ArunKumar,i am a beginner to .NET
if user enters input integer value as :5678
then output should be :5
6
7
8
** Please dont use input variable as string,input variable is int
for ex:
int x=5678; not as string x=5678;
thanks,
ArunKumar.
|
|
|
|
|
In .NET, you can easily convert the integer to string, then get each digit out. So in your example,
int x=5678;
you can declare a string variable
string sx=x.ToString();
After that you just need to use SubString() to extract each digit out of it.
|
|
|
|
|
[Just because you said you don't wanna use string]
use a different complicated process: (just for fun)
int x = 5678;
List<int> values = new List<int>();
while (x > 0)
{
int value = x - ((int)(x / 10) * 10);
values.Add(value);
x = (int)(x / 10);
}
You get all the values in the list but in reverse order. So you can use
values.Reverse();
|
|
|
|
|
int x = 5678;
string asText = string.Format("{0:0 0 0 0}", x);
string[] parts = asText.Split(' ');
for (int i = 0; i < parts.Length; i++)
{
int value = Convert.ToInt32(parts[i]);
}
EDIT ================
This is the 2nd time this week this question has come up. One of the Indian universities must have started up another semester.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
foreach(char c in x.ToString()) Console.WriteLine(c);
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
he didn't want to use a string - check my next answer...
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Here's the "pointless math exercise" version:
int value = 12345;
double i = 1;
double power = 0;
List<int> digits = new List<int>();
while (value > 0)
{
power = Math.Pow(10d, i);
digits.Add(value % (int)power);
value = (int)((double)value / power);
}
digits.Reverse();
EDIT =======================
This is clearly a homework assignment, and to be brutally honest, I see no future for you in programming. If you can't analyze and solve such a simple math problem, you have no business working as a programmer. Yeah, I provided you with the answer, but don't mistake this for a kindness on my part. In fact, I strongly advise you to share this code with your classmates, because if I see this particular request again, I cannot guarantee that I will be kind *or* understanding.
EDIT =======================
Changed digits.Sort() to digits.Reverse() .
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
modified on Saturday, January 23, 2010 7:52 AM
|
|
|
|
|
you have silently assumed the "integer" would fit in an int, in which case I agree with your code.
For larger variables, you would need long and Math.Pow() would lack the accuracy to get it right in all cases...
So the next homework assignment should be: find the smallest positive long value for which JSOP's code fails. Where is the new article category?
[ADDED]
Shall we call the final Sort a typo?
[/ADDED]
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
modified on Friday, January 22, 2010 5:53 PM
|
|
|
|
|
The OP specified an int, so it's all good.
Besides, this is just showing him how to do it, and isn't meant as an all-encompassing fulling vetted and tested method.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
And here's the pointless math exercise that accounts for negative integers:
int value = int.MinValue;
double i = 1;
double power = 0;
List<int> digits = new List<int>();
while (value != 0)
{
power = Math.Pow(10d, i);
digits.Add((value % (int)power) * ((value < -10) ? -1 : 1));
value = (int)((double)value / power);
}
digits.Reverse();
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
modified on Saturday, January 23, 2010 8:27 AM
|
|
|
|
|
And finally, the pointless math exercise extracting the digits from left to right instead of right to left.
bool isNegative = (value < 0);
List<int> digits = new List<int>();
int value = int.MinValue;
double i = 9;
double power = 0;
while (value != 0)
{
power = Math.Pow(10d, i);
int result = (value - (value % (int)power));
int addResult = (int)((double)result / power) * ((isNegative && (int)i == 9) ? 1 : -1);
digits.Add(addResult);
value -= result;
i--;
}
I hope you can see by my persistence that I've found several similar ways to accomplish the stated goal. This is part of what makes a good programmer.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
hi guys
i want to know how to get output of SSRS(another project in the same solution) to win form using c# language (in the same solution) with visual studio 2008
so any articles or answers can help me
thanks
|
|
|
|
|
I'm sorry everyone but I posted the wrong problem so here it goes again..
When you try to set the rightToLeft property inside the modal form, it vanishes..
this.RightToLeft = RightToLeft.Yes;
It's obvious, it's a bug.. Can you think of any workaround??
Thank you everyone!
|
|
|
|