hi guys,
i tried to get some data from my access db. i used repeater to get the data, but i got a problem when i tried to get the data with number type in ms access.
it shown an error.
is there another way to get the data ?
thank you.
7 1666 PRR 750
Expert 512MB
Can you post some sample code? You need to cast before you can "copy" from repeater... also need to check for null values ...
Sample code would really help us understand what you're talking about.
(You can't use a Repeater to retrieve data from a database...but you can use it to display data Retrieved from the database...)
-Frinny
PS
When posting code snippets please remember to use code tags
here is the code. - Sub Page_Load (Source As Object, E as EventArgs)
-
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("surat.mdb") & ";"
-
Dim MySQL As String = "SELECT no, nosurat, tglsurat, kategori, tujuan, perihal, deskripsi FROM surat"
-
Dim MyConn as New OleDBConnection (strConn)
-
Dim Cmd as New OleDBCommand (MySQL, MyConn)
-
MyConn.Open ()
-
rptSurat.DataSource = Cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection)
-
rptSurat.DataBind()
-
End Sub
and for the repeater, -
<asp:Repeater ID="rptSurat" Runat="Server">
-
<HeaderTemplate>
-
<table border=1 cellpadding=5 cellspacing=0 width=50%>
-
</HeaderTemplate>
-
-
<ItemTemplate>
-
-
<tr>
-
<td width=30%><b><font face=Tahoma size=2>No </font></b></td>
-
<td><font face=Tahoma size=2><%#Container.DataItem("no")%></td></tr>
-
<tr>
-
<td width=30%><b><font face=Tahoma size=2>Tanggal Surat </td>
-
<td><font face=Tahoma size=2><%#Container.DataItem("tglSurat")%></td></tr>
-
<tr>
-
<td width=30%><b><font face=Tahoma size=2>Kategori </td>
-
<td><font face=Tahoma size=2><%#Container.DataItem("kategori")%></td></tr>
-
<tr>
-
<td width=30%><b><font face=Tahoma size=2>Tujuan </td>
-
<td><font face=Tahoma size=2><%#Container.DataItem("tujuan")%></td></tr>
-
<tr>
-
<td width=30%><b><font face=Tahoma size=2>Perihal </td>
-
<td><font face=Tahoma size=2><%#Container.DataItem("perihal")%></td></tr>
-
<tr>
-
<td width=30%><b><font face=Tahoma size=2>Deskripsi Isi </td>
-
<td><font face=Tahoma size=2><%#Container.DataItem("deskripsi")%></td></tr>
-
-
</ItemTemplate>
-
-
<SeparatorTemplate>
-
<tr height=25><td></td></tr>
-
</SeparatorTemplate>
-
-
<FooterTemplate>
-
</table>
-
</FooterTemplate>
-
-
</asp:Repeater>
-
no : number type in access.
i couldn't get the data, it shown an error.
Ok, next thing we need to know is what the error message says :)
the error msg is like this : - Exception Details: System.IndexOutOfRangeException: no
-
-
Source Error:
-
-
-
Line 49: <tr>
-
Line 50: <td width=30%><b><font face=Tahoma size=2>Letter No </font></b></td>
-
Line 51: <td><font face=Tahoma size=2><%#Container.DataItem("no")%></td></tr>
-
Line 52: <tr>
-
Line 53: <td width=30%><b><font face=Tahoma size=2>Date </td>
-
-
-
Source File: D:\ASPwebsite\srtView.aspx Line: 51
-
-
Stack Trace:
-
-
-
[IndexOutOfRangeException: no]
-
Microsoft.VisualBasic.CompilerServices.Container.InvokeMethod(Method TargetProcedure, Object[] Arguments, Boolean[] CopyBack, BindingFlags Flags) +202
-
Microsoft.VisualBasic.CompilerServices.NewLateBinding.CallMethod(Container BaseReference, String MethodName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, BindingFlags InvocationFlags, Boolean ReportErrors, ResolutionFailure& Failure) +150
-
Microsoft.VisualBasic.CompilerServices.NewLateBinding.InternalLateIndexGet(Object Instance, Object[] Arguments, String[] ArgumentNames, Boolean ReportErrors, ResolutionFailure& Failure) +166
-
Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateIndexGet(Object Instance, Object[] Arguments, String[] ArgumentNames) +22
-
ASP.srtview_aspx.__DataBind__control4(Object sender, EventArgs e) in D:\ASPwebsite\srtView.aspx:51
-
System.Web.UI.Control.OnDataBinding(EventArgs e) +99
-
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +92
-
System.Web.UI.Control.DataBind() +15
-
System.Web.UI.Control.DataBindChildren() +211
-
System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +102
-
System.Web.UI.Control.DataBind() +15
-
System.Web.UI.WebControls.Repeater.CreateItem(Int32 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem) +124
-
System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource) +443
-
System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e) +51
-
System.Web.UI.WebControls.Repeater.DataBind() +75
-
ASP.srtview_aspx.Page_Load(Object Source, EventArgs E) in D:\ASPwebsite\srtView.aspx:14
-
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
-
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
-
System.Web.UI.Control.OnLoad(EventArgs e) +99
-
System.Web.UI.Control.LoadRecursive() +50
-
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
-
-
error in line 51
I see your problem.
On line 7 of your VB code: @dbdb
You are assigning the DataSource of the repeater to the return value of the ExecuteReader() method.
The ExecuteReader method does not return a Table or any other item that can properly be used as a data source. It returns an OleDbDataReader Object. You would have to use this object (read from the data stored within it) to create a data source that could properly be used with the Repeater.
You could do that, but I'm going to recommend using the OleDataAdpater class to fill a DataSet. Once the OleDataAdapter's Fill method is used to fill a DataSet, the DataSet will contain DataTables which you can use as a data source for your repeater. In your case it's likely that only 1 table will be in the DataSet....so this should be rather straightforward.
Look into how use DataAdapters and DataSets....and if you're really curious, look up how to use a DataReader properly.
The error indicates that the repeater is attempting to read an index that is not present on the datasource.
Make your select statement in a query so that you can see the data it returns. Double check the spelling of your column names and the corresponding indexes used by the data repeater.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: John Ortt |
last post by:
> I have a table of dates in ascending order but with varying intervals. I
> would like to create a query to pull out the date (in field 1) and then
pull
> the date from the subsequent record...
|
by: Geoff Cayzer |
last post by:
At http://www.blueclaw-db.com/tips_tricks.htm I came across a section
which is included below and was hoping for some comment on the
article.
--------------
Almost never use this auto-number...
|
by: CSDunn |
last post by:
Hello,
I have a situation with MS Access 2000 in which I need to display report
data in spreadsheet orientation (much like a datasheet view for a form). If
you think of the report in terms of what...
|
by: Scott269 |
last post by:
So I've got an old MS Works database I imported into Access. I needed
a primary key so I created a record number field that was just the
record number I manually inserted when I entered it in the...
|
by: astro |
last post by:
Anyone have suggestions on where to troubleshoot this error?
Background:
-Access 2k v. 9.0.6926 sp3
- front and backend on production server (wiindows 2k)
-accessed via Citrix
-front-end is...
|
by: james |
last post by:
I have a problem that at first glance seems not that hard to figure out. But, so far, the answer has escaped me. I have an old
database file that has the date(s) stored in it as number of days.
An...
|
by: JaredEmery |
last post by:
Hello all,
It's my first database, and I have a query that shows me the quantity,
material, length, width and thicknesses of parts, and I'm using these
figures to do some arithmetic on a report...
|
by: King |
last post by:
Hi
I have following MS Acess query
Here is the query
ID Name Prgm ID Client ID Date Start Time End
Time Minutes
C4 Trisha TIP DEK0703 7 /7 /2006...
|
by: Hexman |
last post by:
Hello All,
How do I limit the number of detail records selected in a Master-Detail set using SQL?
I want to select all master records for a date, but only the first 3 records for the details...
|
by: S.Dickson |
last post by:
I had an access database that i use as an ordering system. I have a
form for entering customer details. When i add a new customer on the
form the customer number is an auto number that appears when...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
| |