This reference will help you to handle your database easily and quickly.
Download DLL reference DBmanager and add it into your refernces.
Add namespace using DBmanager
Initialize your Connection string
.
DB. MConnectionString = " Your connection" ;
Now you can use this class everywhere in your project like these example.
private void button_Click ( object sender , EventArgs e )
{
DB. MParam. Add ( " ID" , 6 ) ;
DB. MParam. Add ( " fName" , " Kamal" ) ;
DB. MParam. Add ( " lName" , " Nassiri" ) ;
DB. MParam. Add ( " email" , " [email protected] " ) ;
DB. MParam. Add ( " country" , " Libya" ) ;
DB. Insert ( " users" ) ;
}
private void button_Click ( object sender , EventArgs e )
{
DB. Delete ( " users" , " ID=1" ) ;
DB. Delete ( " users" , " fName='Benard'" ) ;
DB. Delete ( " users" , " country='Egypt'" ) ;
}
private void button_Click ( object sender , EventArgs e )
{
// First update
DB. MParam. Add ( " ID" , 10 ) ;
DB. MParam. Add ( " fName" , " Karim" ) ;
DB. MParam. Add ( " lName" , " Khoumani" ) ;
DB. Update ( " users" , " ID=2" ) ;
// Second update
DB. MParam. Add ( " ID" , 60 ) ;
DB. MParam. Add ( " fName" , " Yassine" ) ;
DB. MParam. Add ( " lName" , " Rachidi" ) ;
DB. Update ( " users" , " country='Spain'" ) ;
}
private void button_Click ( object sender , EventArgs e )
{
DB. Select ( " users" ) ;
}
private void button_Click ( object sender , EventArgs e )
{
DB. Select ( " users" , " fName, lName" ) ;
}
fName
lName
Mohammed
Hamham
Thomas
Aubry
Benard
Perret
Jamal
Bensaad
Rachid
Ettouti
private void button_Click ( object sender , EventArgs e )
{
var textBox = " Jama" ;
DB. Select ( " users" , " *" , $" fName LIKE % { textBox } % OR lName LIKE % { textBox } % OR email LIKE % { textBox } % OR country LIKE % { textBox } % " ) ;
}
private void button_Click ( object sender , EventArgs e )
{
var fn = " Rachi" ;
var ln = " Ettouti" ;
var em = " rettouti" ;
var co = " gyp" ;
DB. Select ( " users" , " fName, email" , $" fName LIKE % { fn } % AND lName LIKE % { ln } % AND email LIKE % { em } % AND country LIKE % { co } % " ) ;
}
private void button_Click ( object sender , EventArgs e )
{
var count = DB. Select ( " users" ) . Rows. Count;
MessageBoxshow( count. ToString ( ) ) ;
}
Alert with number of rows 5
var textBoxEmail = " [email protected] " ;
var textBoxPassword = 123 ;
var user = DB. Select ( " users" , " *" , $" columnEmail= { textBoxEmail } && columnPassword= { textBoxPassword } " ) ;
if ( user. Rows. Count > 0 )
{
MessageBox. Show ( " Welcome" ) ;
}
else
{
MessageBox. Show ( " Email or password incorrect" ) ;
}
Copyright © 2021, Mohamed Hamham . Released under the MIT License .