c# - Retrieve data SQL database and display in Gridview on website in Visual Studio 2013 -


i have created website replicates google. search bar allows customers find out if have product require.

  1. the customer searches product on website.
  2. query sent sql
  3. results displayed on website in grid (could multiple items)

i using visual studios build this. have no idea how grab data database create connections , bring results. i'm new , apologise if has been asked.

the steps take implement sql connection when button clicked or whatever requirement sql guide

sqlconnection myconnection = new sqlconnection("user id=username;" +                                     "password=password;server=serverurl;" +                                     "trusted_connection=yes;" +                                     "database=database; " +                                     "connection timeout=30"); 

add gridview page in required position, , set datasource result datareader tutorial here

string strsqlconnection = "data source=dbserver;initial catalog=testdb;integrated security=true"; sqlconnection sqlconnection = new sqlconnection(strsqlconnection); sqlcommand sqlcommand = new sqlcommand("select * table1", sqlconnection); sqlconnection.open();  sqldatareader reader = sqlcommand.executereader();  gridview1.datasource = reader; gridview1.databind(); 

if want know more, try beeing more specific question


Comments

Popular posts from this blog

java - HTTP Status 500 - An exception occurred processing JSP page /second.jsp at line 15 -

SQL Server - MyCTE query based on 24 hour period (next day) -

php - Using str_replace to translate a MySQL Table in html -