|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
firebird & .net provider
Excuse the extreme Newbie question.
I am new to both C# and asp.net I been looking on the web for some examples on how to use the .net provider for firebird. Does anyone know of any? I've installed the .net provider and looked through the SDK documentation but to a newbie it is confusing. Thanks Fr. Robert |
|
#2
|
|||
|
|||
|
What exactly do you need?
Not sure what you are looking for, but here is the connect statements I use:
(dbfile is a string that contains the path to your fbd file) gsConnection="User=SYSDBA;Password=masterkey;Database="+dbfile+";DataSource=localhost;Port=3050;Dialect=3;Charset=NONE;Role=;Connection lifetime=15;Pooling=true;MinPoolSize=0;MaxPoolSize=50;Packet Size=8192;ServerType=0"; gIDbConn = new FirebirdSql.Data.Firebird.FbConnection(gsConnection); gIDbCommand = new FirebirdSql.Data.Firebird.FbCommand(); gIDbCommand.Connection = gIDbConn; gIDAdapt = new FirebirdSql.Data.Firebird.FbDataAdapter(); giDbconn.Open(); |
|
#3
|
||||
|
||||
|
__________________
My blog Tutorials about OSS databases, DBMonster ... Contribute to OSS Development, fill bug reports! Developer Shed eSupport Commented my.ini/my.cnf (ADD YOUR OWN CONFIG TRICK) An introduction to database normalization Natural or Surrogate key Custom ordering for your results Correlated and uncorrelated subqueries Don't turn your outer joins into inner joins Random data (with a bias) |
|
#4
|
|||
|
|||
|
Also there are some examples on the Firebird page.
|
|
#5
|
|||
|
|||
|
firebird * .net provider
Thanks for the help.
It is slowly sinking in. I have a related question. Again excuse the newbie question. Will the datgrid control work with the firebird.net connector? I got it to work if I connected to firebird using ODBC.net connector but not if I used the firebird.net connector. Thanks Again Fr. Robert |
|
#6
|
|||
|
|||
|
got the same problem
Hey frrobert. I got the same problem. I'm new to C# and Firebird. I got the connection established with .net provider and read some data but I can't insert new data into the database. If you find some examples on how to do it please let me know.
Thanks |
|
#7
|
|||
|
|||
|
Here goes a very simple example, not paying attention to best practices
, of how to bind a table to a datagrid and how to insert a new record to the same table.controls in aspx page: - 1 one datagrid - 1 textbox - 1 button Code:
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
BindData();
}
}
private void BindData()
{
FbConnectionStringBuilder cs = new FbConnectionStringBuilder();
cs.DataSource = "localhost";
cs.UserID = "SYSDBA";
cs.Password = "masterkey";
cs.Database = "C:\\Program Files\\Firebird\\data.fdb";
string connectionString = cs.ToString();
FbConnection connection = new FbConnection(connectionString);
connection.Open();
string selectQuery = "SELECT ID, NOME FROM TESTE";
FbDataAdapter da = new FbDataAdapter(selectQuery,connection);
DataSet ds = new DataSet();
da.Fill(ds);
DataGrid1.DataSource = ds;
DataGrid1.DataBind();
connection.Close();
}
private void Button1_Click(object sender, System.EventArgs e)
{
if(TextBox1.Text!= string.Empty)
{
FbConnectionStringBuilder cs = new FbConnectionStringBuilder();
cs.DataSource = "localhost";
cs.UserID = "SYSDBA";
cs.Password = "masterkey";
cs.Database = "C:\\Program Files\\Firebird\\data.fdb";
string connectionString = cs.ToString();
FbConnection connection = new FbConnection(connectionString);
connection.Open();
FbTransaction transaction = connection.BeginTransaction();
string newName = Server.HtmlEncode(TextBox1.Text.Trim());
string insertQuery = "INSERT INTO TESTE(NOME) Values('" + newName + "')";
FbCommand command = new FbCommand(insertQuery, connection, transaction);
command.ExecuteNonQuery();
transaction.Commit();
connection.Close();
TextBox1.Text = string.Empty;
BindData();
}
}
|
|
#8
|
|||
|
|||
|
Thanks
|
![]() |
| Viewing: Dev Shed Forums > Databases > Firebird SQL Development > firebird & .net provider |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|