maked html page CSS and bootstrap now to connect c# and db.
Please reply step by step.
maked html page CSS and bootstrap now to connect c# and db.
Please reply step by step.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Muzaffar Ur RahmanRank #608 · 3.9K reputationPosted Nov 27, 2023, 12:12 AM EST
Hi, could you please find link to connect to DB using C# code.
https://www.c-sharpcorner.com/article/how-to-connect-sql-database-in-asp-net-using-c-sharp-and-insert-and-view-the-data-usi/
Vishal JoshiRank #377 · 6.7K reputationPosted Nov 28, 2023, 5:09 AM EST
Hello Krishna
You can create API using .net and call it from the HTML using jQuery Ajax call or you can use a javascript library like angular or react native to call API.
Simple steps you can try:
Thanks
Vishal Joshi
umair mohsinRank #3,092 · 463 reputationPosted Nov 29, 2023, 2:05 PM EST
it seems you are at the beginning level of learing aspnet.if so then you should first practice using ado.net as it is the basic tool to connect with your db then move further.there are several ways of connecting your app to db.
Sam HobbsRank #107 · 20.5K reputationPosted Nov 29, 2023, 4:09 PM EST
I suggest that you learn Entity Framwork (EF). That will take time to learn but it will save time in the future. Since I use it for ASP.Net applications I have no samples of using a database in ASP.Net applications without EF. I have a simple application that uses SQLite in a WPF application that might help.
You do not say whether you are using SQL Server or some other database. I assume you have already created the database. You will need to have a connection string for the database. The format of the connection string depends on what type of database it is. You can probably use Visual Studio's SQL Server Object Explorer to get the connection string.
The following will read a table from a SQLite database into a
Listcollection whereClipTextis the table name and is also a C# class andDescriptionandDataare fields in the table.List ctl = new List(); // using (SqliteConnection connection = new SqliteConnection(cs)) { connection.Open(); var command = connection.CreateCommand(); command.CommandText = @"SELECT Description, Data FROM ClipText"; using (SqliteDataReader reader = command.ExecuteReader()) { while (reader.Read()) { var name = reader.GetString(0); ClipText ct = new ClipText(); ct.Description = reader["Description"].ToString(); ct.Data = reader["Data"].ToString(); ctl.Add(ct); } } }I am not sure how to get the data into the HTML withour using EF. As I said, I use EF.