|
As the subject suggests, is it possible to store a List<someobject> in a SQL database using stored procedures or any other ADO.NET code?
|
|
|
|
|
|
I second that: yes yes.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Okay any tips on how to do this? Would I just pass it through as a single parameter and specify a data type? I only did a few google searches but it didn't help much. I'll keep searching though. Just a correction on my first post; I meant a generic List(T) (I know it's not supposed to be round brackets)
|
|
|
|
|
there probably is an infinite number of ways to do it, and maybe only a single good one.
you could serialize the List<T> to a stream, maybe an XML stream, and store that in a single field of your database. That stores the data, but makes it completely unavailable, until you read it all back into a list.
the one, structured, way to do it would take an entire table:
a List<T> contains objects of type T, which probably holds a number of data fields.
a database table holds a number of rows and columns.
hence each listed T instance should be stored as a row.
Etienne_123 wrote: I meant List and not just plain list
do you ever use the preview button, and fix what does not look right? you need to encode those < signs, otherwise they are interpreted like HTML here. There are some widgets to help you.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Thanks I will use your comments. Yes I always use the preview button. That's why I said I know that 'T' shouldn't be in round brackets. I was in a hurry and wasn't sure how to encode those signs
|
|
|
|
|
Hi,
Does anyone know about a application like ".NET Reflector" that decompiles an entire DLL?
Thanks
|
|
|
|
|
Yes, it is called .NET Reflector.
AFAIK there is a plug-in that does that. I don't have details though, so try Google!
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Hi every one,
I have created a class: student.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Assignmnet2
{
[Serializable]
public class ITECH3219Student
{
//definition of Class's Field
private string FirstName;
private string SurName;
private int StudentId;
private int LabsMark;
private int Assignment1;
private int Assignment2;
private int Final;
//defination of Class Properties
public string Fr_name
{
get { return FirstName; }
set { FirstName = value; }
}
public string Sr_Name
{
get { return SurName; }
set { SurName = value; }
}
public int St_Id
{
get { return StudentId; }
set { StudentId = value; }
}
public int Lb_Mark
{
get { return LabsMark; }
set
{
if (value > 0 && value <= 10)
{
LabsMark = value;
}
}
}
public int Ass1
{
get { return Assignment1; }
set
{
if (value > 0 && value <= 20)
{
Assignment1 = value;
}
}
}
public int Ass2
{
get { return Assignment2; }
set
{
if (value > 0 && value <= 20)
{
Assignment2 = value;
}
}
}
public int Fnl
{
get { return Final; }
set
{
if (value > 0 && value <= 50)
{
Final = value;
}
}
}
//define Constructor of Class
public ITECH3219Student(string Fr_Name, string Sr_Name, int St_Id, int Lb_Mark, int Ass1, int Ass2, int Fnl)
{
this.FirstName = Fr_Name;
this.SurName = Sr_Name;
this.StudentId = St_Id;
this.LabsMark = Lb_Mark;
this.Assignment1 = Ass1;
this.Assignment2 = Ass2;
this.Final = Fnl;
}
//define the class's methods
public bool Passed()
{
return ((LabsMark + Assignment1 + Assignment2) >= 25 && (Final >= 25));
}
//definition Grade property
public string Grade
{
get
{
int TotalMark = LabsMark + Ass1 + Ass2 + Final;
if (TotalMark < 40) return "F";
else if (((!Passed()) && TotalMark >=50) ||
(TotalMark < 50 && TotalMark >= 40))return "MF";
else if ((Passed()) && TotalMark < 60 && TotalMark >= 50)return "P";
else if ((Passed()) && TotalMark < 70 && TotalMark >= 60)return "C";
else if ((Passed()) && TotalMark < 80 && TotalMark >= 70)return "D";
else if (TotalMark > 80) return "HD";
else
return string.Empty;
}
}
//public static int CompareByName(ITECH3219Student x, ITECH3219Student y)
//public static int CompareByTotal( ITECH3219Student x, ITECH3219Student y)
public override string ToString()
{
return string.Format("Surname:{0}\nFirstName:{1}\nStudentId:{2:D6}",SurName,FirstName,StudentId);
}
}
}
I have anther class which suppose to insert data to a file through list.
The problem is whenever I am trying to add data I get thie error "invalid token '( ' in class struct or interface member declaration"
Class CreateEntry.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Assignmnet2
{
[Serializable]
class CreateEntry
{
ITECH3219Student student = new ITECH3219Student();
List<ITECH3219Student> list_InsertStudent = new List<ITECH3219Student>();
list_InsertStudent.Add(student);
}
}
Could you please tell me whats the problem. I should insert an object to file. my object included those fields which has defined at first class.
Thanks for your help.
|
|
|
|
|
I'm not going to try to read all that -- reduce the problem to the minimum amount of code, then format it properly (use <pre></pre> tags as the instructions say).
|
|
|
|
|
Maybe it will be stupid question, but is this code:
Member 4674360 wrote: using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Assignmnet2
{
[Serializable]
class CreateEntry
{
ITECH3219Student student = new ITECH3219Student();
List<itech3219student> list_InsertStudent = new List<itech3219student>();
list_InsertStudent.Add(student);
}
}
copied directly from your code? If it is, then it's invalid (line list_InsertStudent.Add(student);)
You should add this line in the constructor.
|
|
|
|
|
that is unreadable due to the absence of <PRE> tags
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Sorry, could you repeat that my hearing is going?
It's time for a new signature.
|
|
|
|
|
Richard MacCutchan wrote: my hearing is going?
I'd better not; if I repeat that once more, it will be gone completely. I could send an e-mail though.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
The problem is in here:
public string Grade
{
get
{
int TotalMark = LabsMark + Ass1 + Ass2 + Final;
if (TotalMark < 40) return "F";
else if (((!Passed()) && TotalMark >=50) || // This line should contain another ')' after "TotalMark >= 50)"
(TotalMark < 50 && TotalMark >= 40))return "MF";
else if ((Passed()) && TotalMark < 60 && TotalMark >= 50)return "P";
else if ((Passed()) && TotalMark < 70 && TotalMark >= 60)return "C";
else if ((Passed()) && TotalMark < 80 && TotalMark >= 70)return "D";
else if (TotalMark > 80) return "HD";
else
return string.Empty;
}
}
|
|
|
|
|
You need to fix your compilation errors first. Other posters have pointed to some of them, the following code is obviously wrong
{
[Serializable]
class CreateEntry
{
ITECH3219Student student = new ITECH3219Student();
List<ITECH3219Student> list_InsertStudent = new List<ITECH3219Student>();
list_InsertStudent.Add(student);
}
}
This code needs to be enclosed by a method or constructor.
It's time for a new signature.
|
|
|
|
|
Hi all.
I've search a lot but i haven't find a code in c# that make a Client-Server net that work over internet.
All samples i found work only on LAN.
Can anyone please give me some link of sample that use a Client-Server net working over internet?
Thanks.
|
|
|
|
|
Member 4311057 wrote: I've search a lot but i haven't find
That's because it doesn't exist. If you want to connect applications via the internet then use WebServices.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Did you think about port forwarding? If you skip that on the server, the client can not connect to it.
|
|
|
|
|
I think the port are ok (they're opened i mean,i've open it in the firewall and they seems not to be blocked).
Mark,can you give me a sample were you use webService? (for example a chat)
A chat could be a great example becouse i can change the text message with the data i want to tranfer.
Thanks.
|
|
|
|
|
Ok,i've made a web service that do what i want,the problem is that i can see it only in local network.
How can i made it work (like Apache in PHP) from anywhere in internet ?
Thanks.
|
|
|
|
|
I have a simple C# application that performs some setup tasks and exits, once done, with no user notification. I would like to display a progress dialog showing status. Currently my setup code is in the Run method of the program instance.
I could create two forms. Form A would be not visible and would perform setup tasks. Form A would create Form B that displays progress. Form A could manipulate Form B controls.
This I could have done, but seems unnecessary and not proper. What I was trying to accomplish was including the setup code in the Run function of the program instance. And creating a single progress dialog there. But then I'm missing a message pump for forms? (is that correct wording). Form would not process paint events I'm guessing.
Am I over-thinking this? I would like to accomplish having a thread (maybe original app thread) processing setup tasks, and a separate thread or message pump for form? To accomplish this, I think would help me in understanding more about threading and app processing.
Thanks for your help!
|
|
|
|
|
David Hovey wrote: I could create two forms.
Asynchronous programming might be an answer to your problem.[^]
David Hovey wrote: Am I over-thinking this?
Possibly.
David Hovey wrote: To accomplish this, I think would help me in understanding more about threading and app processing.
That though is true.
My signature "sucks" today
|
|
|
|
|
Use a BackgroundWorker to do the long running tasks and use ReportProgress to update the ProgressBar .
Alternatively, use my ProgressWorker[^] which I made for exactly this purpose.
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
David Hovey wrote: Am I over-thinking this?
Yes. You don't need two forms or to use the Run method.
Have one form the displays the progress indicator and, as Davey, suggests use a Background worker to complete the tasks. Start the background operation from the FormLoad event.
I know the language. I've read a book. - _Madmatt
|
|
|
|