Select from result set of stored procedure

  • Thread starter Thread starter monemas
  • Start date Start date
M

monemas

Guest
hi

I want to show and display data for a specific user from a database that is hosted with a stored procedure.


USE [login_db]
GO
/****** Object: StoredProcedure [dbo].[select_user] Script Date: 5/5/2020 11:22:50 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--select
ALTER proc [dbo].[select_user] (
@id int , @code nvarchar(50),@codeuser nvarchar(50),@pictureuser varbinary(50),@nameshop nvarchar(50),@country nvarchar(50),@addressuser nvarchar(50),@telephone nvarchar(20),@passworact nvarchar(20),@dateregist date,@active bit)
as
select top 1 * from user_tb where active=@active and codeuser=@codeuser
--add



void showdata()
{

cmd = new SqlCommand("select_user", con);
cmd.CommandType = CommandType.StoredProcedure; adapter = new SqlDataAdapter(cmd);
adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
ds = new DataSet(); adapter.Fill(ds, "user_tb");


if (ds.Tables[0].Rows.Count > 0)
{
TEXT_NAME.Text = ds.Tables[0].Rows[rno][3].ToString();
TEXT_ADDRESS.Text = ds.Tables[0].Rows[rno][4].ToString();
TEXT_TEL.Text = ds.Tables[0].Rows[rno][6].ToString();
TEXT_PASSWO.Text = ds.Tables[0].Rows[rno][7].ToString();

pictureBox1.Image = null;
if (ds.Tables[0].Rows[rno][2] != System.DBNull.Value)
{
photo_aray = (byte[])ds.Tables[0].Rows[rno][2];
MemoryStream ms = new MemoryStream(photo_aray);
pictureBox1.Image = Image.FromStream(ms);
}
}

else

MessageBox.Show("No Records");
}

Continue reading...
 
Back
Top