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.
- the customer searches product on website.
- query sent sql
- 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
Post a Comment