Hi!
How do I get my information in the Database to show in a .aspx page?
If I got a rockband starting with the letter B, I want that band to be shown in my .aspx page.
What is the easiest way to accomplish that?
I use C# as programming language.
Best regards
Jonathan
Loading
Kirtan PatelPosted Dec 2, 2009, 12:07 PM
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("You connection String here");
con.Open();
SqlCommand comm = new SqlCommand("select * from YourTableName where Title like 'b%' or Title Like 'B%'", con);
SqlDataAdapter da = new SqlDataAdapter(comm);
DataTable dt = new DataTable();
da.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
con.Close();
}
Hiren SoniPosted Dec 1, 2009, 12:04 PM
Gaurish KumarPosted Dec 1, 2009, 3:27 AM
you can write query like that for fetching the records which starts from character B
SELECT * FROM [TableName] WHERE Title LIKE 'b%'
Jonatan PetterssonPosted Dec 1, 2009, 2:47 AM
The columns I use is as follow:
Id - here is a rockband represent by a number.
Title - the rockband is represent by the name of the band
Info - information about the band goes here.
Image - the URL is set here to find the image.
The problem I have is that I get the rockband on the letter B to show. But I get all rockbands on the other letters on C, D, E etc to show too.
Any ideas how to fix this problem?
Best regards!
Jonathan
Kirtan PatelPosted Nov 30, 2009, 10:14 PM
Can you provide me the Your Database Table Structure - what columns you are having in Table so that i can Provide you the code to accomplish your task :)
Hiren SoniPosted Nov 30, 2009, 10:09 PM