You are on page 1of 2

using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.Odbc;
namespace login2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//OdbcDataReader dr = null;
OdbcConnection con = new OdbcConnection("server=localhost;port=5432;
Dsn=PostgreSQL_coba;uid=postgres;pwd=admin;database=coba_odbc");
con.Open();
//string sql = "SELECT * FROM login WHERE user ='"+t1.Text +"'and pa
ss = '"+t2.Text +"'";
string sql = "INSERT INTO login VALUES ('" + t1.Text + "','" + t2.Te
xt + "')";
OdbcCommand cmd = new OdbcCommand(sql,con);
dr = cmd.ExecuteReader ();
int a;
while( dr.Read ())
{
if (t1.Text == dr[0].ToString() && t2.Text == dr[1].ToString())
{
this.Visible = false;
MessageBox.Show("sukses");
}
else
{
this.Visible = false;
MessageBox.Show("gagal");
}

}

}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'dataSet3.login' tabl
e. You can move, or remove it, as needed.
this.loginTableAdapter1.Fill(this.dataSet3.login);
// TODO: This line of code loads data into the 'dataSet2.login' tabl
e. You can move, or remove it, as needed.
this.loginTableAdapter.Fill(this.dataSet2.login);
}
}
}

You might also like