0

I am using C# and ASP.NEt to create a web application where I need to insert/view data. I created my own class that stores values for a "Ticket" or a support ticket. My question is, how can I grab the values from the SQL table with the tickets and store them in the Ticket class? I don't need the specifics, just what SQL class I should use and how to store them.

Thanks!

4 Answers 4

3

Several options: ADO.NET to query the data using the SqlConnection and SqlDataAdapter, filling the results for a DataTable, and copying the data row data to your Ticket class.

Or even better, use LINQ to SQL or ADO.NET Entity Framework. Plenty of examples of all of this online.

Sign up to request clarification or add additional context in comments.

Comments

1

This tutorial should get you started: http://www.csharp-station.com/Tutorials/ADODotNet/Lesson02.aspx

In the section that reads:

while (rdr.Read())
{
     Console.WriteLine(rdr[0]);
}

You will want replace the Console.WriteLine() with code to to create new instances of Ticket and add them to a ticket list.

Comments

0

You should be able to use a SqlDataReader to get your data, get your column data and place it into your string array.

Comments

0

Have you considered using an ORM? Entity Framework is one the most used.

See this tutorial for more information:

http://www.codeproject.com/Articles/363040/An-Introduction-to-Entity-Framework-for-Absolute-B

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.