3
Answers

How to access Native controls in C# such brightness control?

Photo of Dahen Mustafa

Dahen Mustafa

7y
218
1
Hello, how are you guys? I have a question i hope could answer me!!! How to access “Native controls” in C#? Such as a (volume control, brightness control,...etc). Thanks

Answers (3)

1
Photo of Dharmraj Thakur
NA 4.1k 61.7k 7y
Hi Sudipta,

If you are looking to static print query then Change your stored procedure like below and featch that column in c# as usual...
  1. Declare @query as varchar(max);  
  2. set @query = 'SELECT * FROM ABCD';  
  3. select @query as query; 
0
Photo of Sudipta Saha
NA 41 1.1k 7y
thanks for reply :) ..I dont have too much experience in C# and store procedure.once again thank you for guiding me :)
0
Photo of Suraj Kumar
NA 1.3k 14.4k 7y

Attachment SP_Output.zip

Hi Sudipta,
You can write sql query as below and I have attached the source code also
-- ProcedureQueryOutput 'Suraj Kumar Mandal', ''
ALTER PROCEDURE [dbo].[ProcedureQueryOutput]
(
@EmpName VARCHAR(50),
@SQLQuery NVarchar(2000) out
)
AS
IF EXISTS ( SELECT * FROM EmpTable WHERE EmpName = @EmpName )
BEGIN
SET @SQLQuery = ('SELECT * FROM EmpTable WHERE EmpName =''' + @EmpName +'''')
END
ELSE
BEGIN
SET @SQLQuery = 'INSERT INTO EmpTable (EmpName) VALUES ( '''+ @EmpName +''' )'
END
EXECUTE sp_executesql @SQLQuery
And after that you can call in web form as below
protected void btnGetSQLText_Click(object sender, EventArgs e)
{
string message = String.Empty;
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=TestDB; User Id=sa; Password=password12");
con.Open();
SqlCommand cmd = new SqlCommand("ProcedureQueryOutput", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@EmpName", txtName.Text.Trim().Replace("'","''"));
cmd.Parameters.Add("@SQLQuery", SqlDbType.NVarChar, 500);
cmd.Parameters["@SQLQuery"].Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
message = (string)cmd.Parameters["@SQLQuery"].Value;
con.Close();
}