Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Data.SqlClient;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace zdalnyszkolaWPF
- {
- class SQL
- {
- public User GetUser(string login, string password)
- {
- User user = new User();
- using (SqlConnection connection = new SqlConnection(Properties.Settings.Default.ConnString))
- {
- try
- {
- string sql = string.Format(@"Select UserID,UserLogin,UserPassword from Users
- where UserID = {0} and UserPassword = '{1}'", login, password);
- SqlCommand command = new SqlCommand(sql, connection);
- connection.Open();
- SqlDataReader reader = command.ExecuteReader();
- if (reader.Read())
- {
- user.UserID = Convert.ToInt32(reader["GID"]);
- user.UserLogin = reader["UserLogin"].ToString();
- }
- reader.Close();
- }
- catch (Exception e)
- {
- throw new Exception("GetUser " + e.Message);
- }
- finally
- {
- connection.Close();
- }
- return user;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement