Click here to Skip to main content
15,116,654 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Before I was doing it with XML Database but now I want to Load Products with Sql Server database .
so any one guide me how to connect and how can I load Product in asp.net using sql server database.

Here is My XML Database Code

What I have tried:

Design View Code

<div class="slider slider_circle_10">
          <%=_FeatureProduct %>
       <div class="next_button"></div>
       <div class="prev_button"></div>
   </div>




Source COde

public static string _FeatureProduct;
   protected void Page_Load(object sender, EventArgs e)
   {

       _FeatureProduct = String.Empty;
       dsFeatureProduct dsFeatureProduct = new dsFeatureProduct();
       dsFeatureProduct.ReadXml(Server.MapPath("~/Dataxml/FeatureProduct.xml"));
       foreach (dsFeatureProduct.Idea_FeatureProductRow objSlideRow in dsFeatureProduct.Tables[0].Rows)
       {

           _FeatureProduct = _FeatureProduct + "<a ' href='Product.aspx?Search=" + objSlideRow["ProductTitle"].ToString() + "'><div><img class='productpage' src='img/FeatureProduct/" + objSlideRow.ProductImage.Replace("~/img/FeatureProduct/", "") + "' width='100%' height='100%' /></div></a>";

       }

   }
Posted
Updated 6-Feb-21 0:34am

1 solution

See example here: ASP.NET Web Pages Databases[^]
(note that a SQL Server Compact database is used in the example)

You will have to define a connectionstring first when working with a "normal" SQL Server version, see: Insert, Update, Delete: ASP.NET Database Connection Tutorial[^]

SQL Server is not an easy database to work with, for beginners I recommend using LiteDB[^]
   
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900