I need to store C# object and object id in sql server db. Ex, student object having stid, name, addr and retrieve it using the stid. Can anyone provide a solution please?
Store and retrieve objects - Please help
Collapse
X
-
You have to be able to create a table on a server side. Connect to the database and use simple Insert to store data and Select to retrieve it.
From your question I assume that you have very little knowledge of it and you need a lot to learn before starting project like this.
Sorry... :( -
Originally posted by iburyakYou have to be able to create a table on a server side. Connect to the database and use simple Insert to store data and Select to retrieve it.
From your question I assume that you have very little knowledge of it and you need a lot to learn before starting project like this.
Sorry... :(
Hi,
I want to know that, the thing i need to insert is an object. In this case the object of the student class. Then is should be stored in a db table as a binary in one column and the stid in the other column as the key. When it requires, it should be possilbe to retrive that object using the stid and use in the application. Hope its clarify the prob.Comment
-
No you don't save objects on a database side.
You just save values in a table and when you will retrieve this data from a database you will be able to create empty object and assign values received from a database to it.
1. Create a table:
[PHP]Create table Student(
stid int,
name varchar(50),
addr varchar(500))[/PHP]
2. Store data from each object:
[PHP]Insert into table Student values (StudentID_here , StudentName_her e, Address)[/PHP]
3. Retrieve data and create an object
[PHP]Select stid, name, address from Student where stid = StudentID_here[/PHP]Comment
-
Originally posted by iburyakNo you don't save objects on a database side.
You just save values in a table and when you will retrieve this data from a database you will be able to create empty object and assign values received from a database to it.
1. Create a table:
[PHP]Create table Student(
stid int,
name varchar(50),
addr varchar(500))[/PHP]
2. Store data from each object:
[PHP]Insert into table Student values (StudentID_here , StudentName_her e, Address)[/PHP]
3. Retrieve data and create an object
[PHP]Select stid, name, address from Student where stid = StudentID_here[/PHP]
Hi,
Thanks, but here is an special requirement to store an object as i stated above. The application is developed using asp.net c#. Do you have any solution for it?Comment
-
Thanks for your response! It's great to see new people adding their knowledge to the community. I believe, however, that you are wrong about not being able to store an object in the database. You can do all kinds of things with serialized object; send them over the network, save them to disk, and yes, they can be put in a DB.Originally posted by CoolRiyazIf you want to store the objects please read 'Object Serialization'.
But you can not store it in db, they will be stored on hard diskComment
-
Hi,
Thanks for everyone who replied for this problem posted by myself. Recenly I found a good article which provides an excellent answer for this question. Follow the link below anyone who is interested.
Thanks
SudanthaLast edited by Banfa; Apr 8 '07, 10:21 PM. Reason: Email Address removed in accordance with posting guidelinesComment
-
Thanks for posting the article!Originally posted by SudanthaHi,
Thanks for everyone who replied for this problem posted by myself. Recenly I found a good article which provides an excellent answer for this question. Follow the link below anyone who is interested.
Thanks
SudanthaLast edited by Banfa; Apr 8 '07, 10:22 PM. Reason: Email Address removed in accordance with posting guidelinesComment
Comment