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

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -