|
| problem in getting records from oracle database... |
 |
Thu, 27 Mar 2008 08:53:56 +000 |
hi frnds... Please help me in this query....
i am using vs2005,asp.net,vb code,oracle database...
my scenario is like this...
i have four link buttons in my webform.. first,next,previous,last...
Imports System.Data
Imports System.Data.oledb
Partial Class District
Inherits System.Web.UI.Page
Dim con As New OleDbConnection("provider=msdaora.1;user
id=civil;password=civil")
Dim da As New OleDbDataAdapter("select * from district", con)
Dim ds As New DataSet Dim cb As New OleDbCommandBuilder
Dim N As Byte
Private Sub filldata(ByVal rno As Byte)
With ds.Tables("district").Rows(rno)
txtdcode.Text = .Item(0)
txtdname.Text = .Item(1)
End With
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
da.MissingSchemaAction = MissingSchemaAction.AddWithKey
da.Fill(ds, "district") cb = New OleDbCommandBuilder(da)
Call filldata(N)
End
Sub Protected Sub btnFirst_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnFirst.Click
N = 0
Call filldata(N)
End Sub
Protected Sub btnnext_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles btnnext.Click
If N < ds.Tables("district").Rows.Count - 1 Then
N += 1
Call filldata(N)
Else
MsgBox("last record")
End If
End Sub
Protected Sub btnprevious_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnprevious.Click
If N > 0
Then N -= 1
Call filldata(N)
Else
MsgBox("first record")
End If
End Sub Protected Sub btnlast_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnlast.Click
N = ds.Tables("district").Rows.Count - 1
Call filldata(N)
End Sub
the problem is ,when i click next button its working for only one
record..,previous button is not working...
please help me out...soon....
its very urgent...
thank u
in advance
|
| Post Reply
|
| Re: problem in getting records from oracle database... |
 |
Fri, 28 Mar 2008 06:41:38 +000 |
Read up on using a FormView or DetailsView control, and set AllowPaging = True,
and you're in business. Though if you have hundreds of records in your db
table, you may want to tap into the db process and use a query to only select 1
record at a time.
|
| Post Reply
|
| Re: problem in getting records from oracle database... |
 |
Mon, 31 Mar 2008 13:33:24 +000 |
Use OleDbDataReader to achieve your objective.
No need to use dataset as it gets all the Records from Database Table....[ More
rows..More Memory...Less Performance...etc..etc..]
you can use following example to fit into your scenario...
using System.Data.OleDb;
OleDbConnection Oraclecon = new
OleDbConnection("Provider=MSDAORA.1;Password=tiger;"
+ "User ID=scott;Data Source=OracleServer;Persist Security
Info=True");
Oraclecon.Open();
OleDbCommand myCMD = new OleDbCommand
("{call curspkg_join.open_join_cursor1(?, {resultset 0, io_cursor})}",
Oraclecon);
myCMD.Parameters.Add("ID", OleDbType.Numeric, 4).Value = 0;
OleDbDataReader myReader;
myReader = myCMD.ExecuteReader();
int x;
int count;
count = 0;
while (myReader.Read())
{
for (x = 0; x <= myReader.FieldCount - 1; x++)
Console.Write(myReader.GetValue(x) + " ");
Console.WriteLine();
count += 1;
}
MessageBox.Show(count + " Rows Returned.");
myReader.Close();
Oraclecon.Close();
|
| Post Reply
|
|
|
|
|
|
|
|
|
|