DataGrid && Oracle stored procedure

prem_rajani

Member
Joined
Jul 19, 2005
Messages
22
Location
Coimbatore
Programming Experience
3-5
Hi,

How to populate datagrid with values got from oracle stored procedure. When I bind datagrid nothing seems to be displayed. The code is as follows:

VB.NET:
[SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] cmdQuery [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] OleDbCommand(trvSP.SelectedNode.Text, OleConn)
cmdQuery.CommandType = CommandType.StoredProcedure
[/SIZE][SIZE=2]'This if no parameters[/SIZE][SIZE=2][COLOR=#0000ff][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] daQuery [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] OleDbDataAdapter(cmdQuery)
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] dsQuery [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] DataSet
daQuery.Fill(dsQuery)
dgResult.DataSource = dsQuery
[/SIZE][SIZE=2] 
'If parameters exist
strsplit = Split(rtbParam.Text, ",")
[/SIZE][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] I = 0 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] ParamList.Count - 1
cmdQuery.Parameters.Add(ParamList.Item(I), strsplit(I))
[/SIZE][SIZE=2][COLOR=#0000ff]Next
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] daQuery [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] OleDbDataAdapter(cmdQuery)
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] dsQuery [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] DataSet
daQuery.Fill(dsQuery)
dgResult.DataSource = dsQuery
[/SIZE]


The procedure is as follows:
VB.NET:
create procedure Users (
username varchar2,user out varchar2)
as
name varchar2(10);
pwd varchar2(10);
begin
select username ,userpass into name,pwd from CC_M_USERPREV_H
where username=username;
--dbms_output.put_line(name);
--dbms_output.put_line(pwd);
end;

Can anyone help me out pls?
Note: Datagrid doesnt get populated
 
After setting the DataSource of the grid, also set the DataMember property.

For more info, there's an intro to ado.net in my sig that covers this.

-tg
 
It doesnt work

Hi,

After even setting the data member it doesnt display anything. But rather it gives error "Cannot create a child list for field users.
 
Back
Top