Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
2
Answers
Class FireBird Help me.
Purba Anggara
8y
427
1
Reply
Example SQL connection
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
using
System.Data;
using
MySql.Data.MySqlClient;
namespace
Perpustakaan
{
class
Example
{
}
class
DbMySQL
{
string ConnString ;
public
DbMySQL()
{
ConnString=
"DataSource=localhost;Username=root;password=;Database=db_perpus_ik3"
;
}
// -- jenis Query
// Query Pemilihan Data -> Select <namafield> FROM <namatabel> [WHERE kondisi]
public
DataTable GetDataTable(string Query)
{
DataTable result =
new
DataTable();
MySqlConnection MyConn =
new
MySqlConnection(ConnString);
MyConn.Open();
MySqlCommand MyComm =
new
MySqlCommand(Query, MyConn);
MySqlDataReader myReader = MyComm.ExecuteReader();
result.Load(myReader);
MyConn.Close();
return
result;
}
// Query Manipulasi Data
// -> tambah data > INSERT INTO <namatabel> (namafield1,namafield2,..) VALUES ('nilaifield1','nilaifield2',..)
// -> rubah data > UPDATE <namatabel> SET namafield='nilaifield',namafield2=nilaifield2,.. [WHERE kondisi]
// -> hapus data > DELETE FROM <namatabel> [where kondisi]
public
void
ExecuteNonQuery(string Query)
{
MySqlConnection myConn =
new
MySqlConnection(ConnString);
myConn.Open();
MySqlCommand myComm =
new
MySqlCommand(Query, myConn);
myComm.ExecuteNonQuery();
myConn.Close();
}
}
}
FireBird Class ??? Example ??? Please ???
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
Why doesnt this work?
c# book(learning)