Hi Guys Can you help me please in my project, I have tblItemList in my SQL DB. I want to display all the data in my tblItemList in GridView control....
How Can I Do That in VB Script using VB.Net...
Thank you...
Please Help Me...
Regards,
Jared
6 12939
Hi Guys Can you help me please in my project, I have tblItemList in my SQL DB. I want to display all the data in my tblItemList in GridView control....
How Can I Do That in VB Script using VB.Net...
Thank you...
Please Help Me...
Hi jeffstl,
Thanks for your reply, I appreciate it, but I got an error when I write the code below.... The Error Message: Type 'System.data.sqlclient.reader' has no constructors
What should I do? can help me please to debug my code...I'm using MSSQL 2005 as my database and I used ASP.Net in developing the system and VB script.
thank you.... -
---------Name Space----------
-
<%@ Import Namespace="System.Data" %>
-
<%@ Import Namespace="System.Data.SqlClient" %>
-
<%@ Import Namespace="system.data.sqlclient.sqldatareader" %>
-
-
--------VB Script-------------------
-
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
-
-
Dim con As New SqlConnection
-
-
con.ConnectionString = "Integrated Security=True;data source=ph-erwinm1;" & "persist security info=false;Initial Catalog=ITP"
-
Dim strSql As String
-
Dim SQLComm As New SqlCommand
-
Dim dbread As New SqlDataReader
-
-
-
strSql = "SELECT intITPCodeFK,intQuantity FROM tblItemlist"
-
SQLComm = New SqlCommand(strSql, con)
-
dbread = SQLComm.ExecuteReader()
-
GridITPSumm.DataSource = dbread
-
GridITPSumm.DataBind()
-
-
dbread.Close()
-
con.Close()
-
-
End Sub
-
-
-
-
------------------HTML-----------------------
-
<asp:DataGrid id="GridITPSumm" runat="server"
-
AutoGenerateColumns="False" CellPadding="3"
-
HeaderStyle-BackColor="#A4A6CF"
-
HeaderStyle-ForeColor="000033"
-
HeaderStyle-HorizontalAlign="Left"
-
HeaderStyle-Font-Bold="True"
-
BackColor="#eeeeee" Width="50%"
-
HorizontalAlign="Left"
-
Font-Bold="True"
-
Font-Names="Tahoma"
-
Font-Size="10pt">
-
-
<AlternatingItemStyle BackColor="White" />
-
-
<Columns>
-
<asp:BoundColumn HeaderText="ITP COde" DataField="intITPCodeFK" />
-
<asp:BoundColumn HeaderText="QTY" DataField="intQuantity" />
-
</Columns>
-
</asp:DataGrid>
I dont know that much about namespace, or if thats actually the problem but I did notice a few things.
You need the <script> tags around your code-behind, and you also need to open your database connection
see below changes -
-
---------Name Space----------
-
<%@ Import Namespace="System.Data" %>
-
<%@ Import Namespace="System.Data.SqlClient" %>
-
<%@ Import Namespace="system.data.sqlclient.sqldatareader" %>
-
-
--------VB Script-------------------
-
-
'ADD SCRIPT TAG
-
<script runat="server">
-
-
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
-
-
Dim con As New SqlConnection
-
-
con.ConnectionString = "Integrated Security=True;data source=ph-erwinm1;" & "persist security info=false;Initial Catalog=ITP"
-
Dim strSql As String
-
Dim SQLComm As New SqlCommand
-
Dim dbread As New SqlDataReader
-
-
'OPEN DB CONNECTION
-
con.Open
-
-
strSql = "SELECT intITPCodeFK,intQuantity FROM tblItemlist"
-
SQLComm = New SqlCommand(strSql, con)
-
dbread = SQLComm.ExecuteReader()
-
GridITPSumm.DataSource = dbread
-
GridITPSumm.DataBind()
-
-
dbread.Close()
-
con.Close()
-
-
End Sub
-
-
'CLOSE SCRIPT TAG
-
</Script>
-
------------------HTML-----------------------
-
<asp:DataGrid id="GridITPSumm" runat="server"
-
AutoGenerateColumns="False" CellPadding="3"
-
HeaderStyle-BackColor="#A4A6CF"
-
HeaderStyle-ForeColor="000033"
-
HeaderStyle-HorizontalAlign="Left"
-
HeaderStyle-Font-Bold="True"
-
BackColor="#eeeeee" Width="50%"
-
HorizontalAlign="Left"
-
Font-Bold="True"
-
Font-Names="Tahoma"
-
Font-Size="10pt">
-
-
<AlternatingItemStyle BackColor="White" />
-
-
<Columns>
-
<asp:BoundColumn HeaderText="ITP COde" DataField="intITPCodeFK" />
-
<asp:BoundColumn HeaderText="QTY" DataField="intQuantity" />
-
</Columns>
-
</asp:DataGrid>
-
-
hi guys,
can you help me please....
I'm using asp.net,mssql server2005 and vb script....
i dont know how to display data from db to gridview....
i want to use datatable in displaying data, so that i can edit,select and can allow paging to my gridview control.
Thank You in advance I appreciate your support...
I dont know that much about namespace, or if thats actually the problem but I did notice a few things.
You need the <script> tags around your code-behind, and you also need to open your database connection
see below changes -
-
---------Name Space----------
-
<%@ Import Namespace="System.Data" %>
-
<%@ Import Namespace="System.Data.SqlClient" %>
-
<%@ Import Namespace="system.data.sqlclient.sqldatareader" %>
-
-
--------VB Script-------------------
-
-
'ADD SCRIPT TAG
-
<script runat="server">
-
-
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
-
-
Dim con As New SqlConnection
-
-
con.ConnectionString = "Integrated Security=True;data source=ph-erwinm1;" & "persist security info=false;Initial Catalog=ITP"
-
Dim strSql As String
-
Dim SQLComm As New SqlCommand
-
Dim dbread As New SqlDataReader
-
-
'OPEN DB CONNECTION
-
con.Open
-
-
strSql = "SELECT intITPCodeFK,intQuantity FROM tblItemlist"
-
SQLComm = New SqlCommand(strSql, con)
-
dbread = SQLComm.ExecuteReader()
-
GridITPSumm.DataSource = dbread
-
GridITPSumm.DataBind()
-
-
dbread.Close()
-
con.Close()
-
-
End Sub
-
-
'CLOSE SCRIPT TAG
-
</Script>
-
------------------HTML-----------------------
-
<asp:DataGrid id="GridITPSumm" runat="server"
-
AutoGenerateColumns="False" CellPadding="3"
-
HeaderStyle-BackColor="#A4A6CF"
-
HeaderStyle-ForeColor="000033"
-
HeaderStyle-HorizontalAlign="Left"
-
HeaderStyle-Font-Bold="True"
-
BackColor="#eeeeee" Width="50%"
-
HorizontalAlign="Left"
-
Font-Bold="True"
-
Font-Names="Tahoma"
-
Font-Size="10pt">
-
-
<AlternatingItemStyle BackColor="White" />
-
-
<Columns>
-
<asp:BoundColumn HeaderText="ITP COde" DataField="intITPCodeFK" />
-
<asp:BoundColumn HeaderText="QTY" DataField="intQuantity" />
-
</Columns>
-
</asp:DataGrid>
-
-
Hey jeffstl thank you...
but i have a problem in binding data in gridview because of using SqlDataReader, I can't allow paging in my gridview because it is readonly, how can i allow paging in my gridview?
thank you...
please help
Sign in to post your reply or Sign up for a free account.
Similar topics
by: washoetech |
last post by:
Hello,
I am working on a project where I need to be able to grab the data from an
Excel spreadsheet and create a new table in my database based on the columns
in the spreadsheet. After the...
|
by: Robert Smith jr. |
last post by:
Hello,
Please pardon my newbie question ...
I am building an ASP.NET page that displays a recordset with a Delete
statement enabled (this all works fine). I want to Insert the current
row...
|
by: |
last post by:
Hello,
Does anyone have an idea on how I can filter the data in the gridview
control that was returned by an sql query?
I have a gridview that works fine when I populate it with data. Now I...
|
by: Siva |
last post by:
Hi,
I have a 3 tier ASP.Net app for a handheld which needs to fetch
orders from database via a DAL and populate it in a gridview using
objectdatasource. In the search page I have a few parameters...
|
by: sutphinwb |
last post by:
Hi - This could be a simple question. When I relate two tables in a
datasetet, how do I get that relation to show up in a GridView? The
only way I've done it, is to create a separate table in the...
|
by: Greg Lyles |
last post by:
Hi all,
I'm trying to develop an ASP.NET 2.0 website and am running into some
real problems with what I thought would be a relatively simple thing
to do.
In a nutshell, I'm stuck on trying to...
|
by: Mike |
last post by:
I'm using the 2.0 framework and cannot get a gridview to return records
with an objectDataSource.
I can preview the data from the datatable.
To make this as simple as possible I used the wizard...
|
by: Adam Sandler |
last post by:
Hello,
Prior to posting I looked at http://groups.google.com/group/
microsoft.public.dotnet.framework.aspnet/browse_thread/thread/
d8d5ae243614085e/d4fd6c4a5aa56f75
...
|
by: chike_oji |
last post by:
Please can someone help me. I am writing a web application,
that allows for the upload of an excel sheet into the database.
I have an upload button and a save button.
The upload button allows...
|
by: Dave |
last post by:
I'm having problems getting the GridView to reliably display a large
amount of data (50,000+ rows).
I am working my way through the excellent book “Real World ASP.NET
Best Practices” by Farhan...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |