I am working on a personal project to display information on a webpage. I haven't done SQL connections in over a year and this is also my first time using dapper so I am having trouble getting started. I have a table (dbo.BallData
) stored in a database using SQL Server Management Studio:
+-------+-----------+---------------+--------------+-------------+-------------+--------------+---------+
| ID | COMPANY | NAME | WEIGHT (lbs) | CORE | COVERSTOCK | SURFACE | LAYOUT |
| 1 | Hammer | True Blood | 15 | First Blood | Polyester | 4000 Polish | NULL |
| 2 | Columbia | Eruption Pro | 15 | Resurgence | CR300 | 1500 Polish | NULL |
+-------+-----------+---------------+--------------+-------------+-------------+--------------+---------+
I would like to display the information as follows. Currently the information is just typed out in HTML:
Company: Hammer
Name: True Blood
Weight (lbs): 15
Core: First Blood
Coverstock: Polyester
Surface: 4000 Polish
Layout:
I am working in C#, but cannot remember how to connect to a sql server database from visual studio. I am just hoping that someone can get started and then I can go from there. I have dapper included in my project. I have a file named BallData.cs where I am trying to connect to the database so that I can pull data out of it. Currently the file is just bare-boned because, like I said, I don't know where to begin.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
namespace PracticeApp.App_Code.Entities
{
public class BallData
{
}
}
Any help would be greatly appreciated. Whether it is pointing me to a tutorial or giving some examples to help me get going. Of course, I am not looking for the completed app. I am just looking for help on getting connected and applying dapper so that I can get in the information displayed. Thank you to anyone who is willing to assist me!
Copyright Notice:Content Author:「」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/23891550/getting-started-with-dapper-and-sql-server-database