I Already connected my SQL database with visual studio via server explorer And i filled some tables with values.
Now, I want to access/search through a table from my SQL database in my visual studio project.
For example: in my table i have products from different categories and i only want to display products from a specific category
But, how can in do that?
There is many ways by which you can access.If you are using connected mode Than you have to create object for connection string
SqlConnection con = new SqlConnection(@"Data Source=nameof_server;Initial Catalog=name_of_database;Integrated Security=True"); SqlCommand cmd = new SqlCommand("sql_command",con); con.open() //perform action based on your requirment ExecuteNonQuery() // Use this for insert,update,delete ExecuteScalar() // Use this for select single column ExecuteReader() // Use this for select multiple records con.close()