using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data.SqlClient;
namespace WpfApplication2
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
Window1 st;
private void btnlogin_Click(object sender, RoutedEventArgs e)
{
SqlConnection con = new SqlConnection(@"Data Source=WELCOM-PC\SQLEXPRESS;Initial Catalog=Test;Integrated Security=True");
SqlDataAdapter sdt = new SqlDataAdapter("Select count (*) from login where id='" + txtid.Text + "'and pass = '" + txtpass.Password + "'", con);
if (txtid==1)
{
if (txtpass.ToString()== 1)
{
this.Hide();
st = new Window1();
st.Show();
}
else
{
MessageBox.Show("Login Failed");
}
}
else
{
MessageBox.Show("Buon");
}
}
}
}
Đậy là đoạn code về phần giao diện màn hình đăng nhập của mình. Và mình đang bí ở chỗ lấy dữ liệu từ database để truy cập vào wpf form khác. Anh em có thể giúp mình
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?