June 29, 2020 13:09 by
Peter
In this function, the SQL procedure table reads a procedure call method in the .NET Core application for the basic console write to get the input value to the search result. The SQL procedure calls to select the statement from the database.
SQL Procedure
CREATE PROCEDURE procselect @username nchar(10)
AS
select * from wincurd where username=@username
go
Basic string console values get functionality:
string val;
Console.Write("Enter value: ");
val = Console.ReadLine();
string a = Convert.ToString(val);
Console.WriteLine("Your input: {0}", a);
SQL Connection string functionality:
SqlConnection dc = new SqlConnection("Data Source=.;Initial Catalog=databasename;Integrated Security=True");
Command Execution Functionality
using(SqlCommand cmd = new SqlCommand("procselect", dc)) {
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@username", a.ToString());
dc.Open();
SqlDataReader dr;
dr = cmd.ExecuteReader();
if (!dr.Read()) {
Console.Write("Record not found ");
} else {
string b = Convert.ToString(val);
b = dr[1].ToString();
Console.WriteLine("Your PASSWORD: {0}", b.ToString());
Console.ReadLine();
}
dc.Close();
}