hi guys can you help me create a database login form of this code to windows form application? Because this code is made for console application. also I already know how to create a database but I do not know how I can make a windows login form for this code, can someone manipulate this for me plsss, It's quite confusing for me right now, Thanks to those who will help.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Sql;
using System.Data.SqlClient;
namespace C_database
{
class Program
{
static void Main(string[] args)
{
string conectionstring = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True";
SqlConnection connection = new SqlConnection(conectionstring);
try
{
connection.Open();
Console.WriteLine("Connection Open");
Console.WriteLine("");
}
catch (Exception e)
{
Console.WriteLine(e);
Console.Read();
}
Console.Write("Username> ");
string username = Console.ReadLine();
Console.Write("Password> ");
string password = Console.ReadLine();
SqlCommand command = new SqlCommand("SELECT * FROM [Table1] WHERE Username='" + username + "' AND Password='" + password + "'", connection);
SqlDataReader reader = null;
reader = command.ExecuteReader();
while (reader.Read())
{
Console.WriteLine("Welcome: " + reader["username"].ToString());
Console.Read();
}
Console.WriteLine("User: " + username + "does not exist");
Console.WriteLine("Press any key to continue");
Console.Read();
}
}
}