.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> VB.Net >> Post New QuestionBookmark and Share Subscribe to Forum

Database

Posted By: srini     Posted Date: November 17, 2010    Points:2   Category :VB.Net
Hello Everyone!

I am developing one application using vb.net and SQL server 2005. I am having Qusetion and answer column in database. I just wanted to retrieve all the data's(for ex:table contains 10 questions and 10 answers)from database and show it into vb.net form having Labels control.

Help me!



Responses
Author: Asha.MP             
Posted Date: November 17, 2010     Points: 5   

Hi..

You need to display the count right?? you can use select count(*) from table query to display the data count.


Thanks and Regards,
Asha.mp
Author: srini             
Posted Date: November 17, 2010     Points: 5   

Asha,

I dont want to count the rows in a table. I wanted to display all the rows and columns data in a table,while loading the form itself.

Help me!

Thanks,
Srini.

Srini
Author: Dhivakaran             
Posted Date: November 22, 2010     Points: 5   


For that you can go gridview.

<asp:GridView ID="grdData" BorderColor="Black" runat="server" AutoGenerateColumns="False" >
<Columns>
<asp:TemplateField HeaderText="Qustion">
<ItemStyle Width="60px"/>
<ItemTemplate>
<asp:Label ID="lblQns" runat="server" Text='<%#Eval("qns")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Answer">
<ItemStyle Width="60px"/>
<ItemTemplate>
<asp:Label ID="lblAns" runat="server" Text='<%#Eval("ans ")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

then in code behind

private void bindgrid()
{
DataSet dt = new DataSet();
string sql ="Select qns,ans from tblname";
SqlConnection sqlcon = new SqlConnection("connectionstring");
SqlCommand cmd=new SqlCommand();
SqlDataAdapter da =new SqlDataAdapter(cmd,sqlcon);
da.Fill(dt);
if (dt.Rows.Count > 0)
{
grdData.DataSource = dt;
grdData.DataBind();
}
}

-
Dhivakaran T


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend