I have created a website which replicates something like google. It is simply a search bar that allows customers to find out if we have the product they require.
I am currently using Visual Studios to build this. But I have no idea how to grab data from my database to create that connections and bring back some results. I'm new to this and I apologise if this has been asked.
The steps to take would be to implement a SQL connection when a button is clicked or whatever your requirement is Sql guide
SqlConnection myConnection = new SqlConnection("user id=username;" +
"password=password;server=serverurl;" +
"Trusted_Connection=yes;" +
"database=database; " +
"connection timeout=30");
Add a Gridview to your page in required position, and set the datasource as the result from your datareader tutorial here
string strSQLconnection = "Data Source=dbServer;Initial Catalog=testDB;Integrated Security=True";
SqlConnection sqlConnection = new SqlConnection(strSQLconnection);
SqlCommand sqlCommand = new SqlCommand("select * from table1", sqlConnection);
sqlConnection.Open();
SqlDataReader reader = sqlCommand.ExecuteReader();
GridView1.DataSource = reader;
GridView1.DataBind();
If you want to know more, try beeing more specific with your question
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.