From: Andrew G. <ag...@jc...> - 2003-06-20 13:33:27
|
http://info.borland.com/devsupport/interbase/opensource/ <-- where you can get interbase open source http://sourceforge.net/project/showfiles.php?group_id=9028 <--- see firebird-net-provider I'm using Webmatrix to code my asp.net webforms with VB codebehind. See http://www.asp.net/webmatrix/default.aspx?tabIndex=4&tabId=46 Hey I like as much free stuff as I can get my hands on :) Here's some examples in VB one for a reader, a dataadapter, and a ExecuteNonQuery. I save the result to an xml file that I can use later instead of pounding the database with more queries. Note on the ExecuteNonQuery you have to have a Commit to get it to work unlike SQL Client or OleDb Client. <%@ Page Language="VB" Debug="true" %> <%@ import Namespace="System.Data" %> <%@ import Namespace="FirebirdSql.Data.Firebird" %> <script runat="server"> Dim public shared myConnectionString As String Dim public shared myConnection As FbConnection Dim public shared myTxn As FbTransaction Dim public shared selectCmd As String Dim public shared mycommand As FbCommand Dim public shared myReader As FbDataReader Dim shared myXMLfile As String = "data.xml" Sub Connect() myConnectionString = "Database=C:\\interbase\\xxx\\xxx.GDB;User=xxx;Password=xxx;Dialect=3;Server =localhost;Pooling=False" myConnection = new FbConnection(myConnectionString) End Sub Sub Page_Load(Sender As Object, E As EventArgs) If Not (IsPostBack) 'Start postback Connect() myConnection.Open() selectCmd ="SELECT * FROM TBLSYSTEMS" myTxn = myConnection.BeginTransaction() myCommand = new FbCommand(selectCmd,myConnection,myTxn) myReader = myCommand.ExecuteReader() selectsystem.DataSource = myReader selectsystem.DataBind() myReader.close() myTxn.Dispose() myCommand.Dispose() myConnection.Close() End If 'End postback End Sub Sub BindGrid() Dim dataAdapter As FbDataAdapter Dim DS As New DataSet() Connect() myConnection.Open() dataAdapter = new FbDataAdapter() myTxn = myConnection.BeginTransaction() selectCmd = "SELECT * FROM QRYDB(@sdate,@edate,@alias) " myCommand = new FbCommand(selectCmd,myConnection,MyTxn) myCommand.parameters.add("@sdate",fbtype.date) myCommand.parameters("@sdate").value = DateAdd("h",-1,DateTime.Now) myCommand.parameters.add("@edate",fbtype.date) myCommand.parameters("@edate").value = DateAdd("h",1,DateTime.Now) myCommand.parameters.add("@alias",fbtype.VARCHAR,20) myCommand.parameters("@alias").value = strCPU Try dataAdapter.SelectCommand = myCommand dataAdapter.Fill(DS, "TempInfo") 'filldataset mydatagrid.DataSource = DS.Tables("TempInfo") mydatagrid.DataBind() dataAdapter.Dispose() myTxn.Dispose() myCommand.Dispose() myConnection.Close() Message2.Style("color") = "green" Message2.InnerHtml = "Matching Records = " & myDataGrid.Items.Count Catch Exp As FbException Message.Style("color") = "red" Message.InnerHtml = "ERROR:" & Exp.Message & "<br>" & selectcmd myTxn.Dispose() myCommand.Dispose() myConnection.Close() Exit Sub End Try DS.WriteXml(Server.MapPath(myXMLfile),XmlWriteMode.WriteSchema) End Sub Sub BindXML() Dim myDataSet as New DataSet() Dim fsReadXml As New System.IO.FileStream(Server.MapPath(myXMLfile), System.IO.FileMode.Open) Dim myView As New DataView() Try myDataSet.ReadXml(fsReadXml) myView = myDataSet.Tables(0).DefaultView mydatagrid.DataSource = myView mydatagrid.DataBind() Message2.Style("color") = "green" Message2.InnerHtml = "Matching Records = " & myDataGrid.Items.Count Catch ex As Exception Message.Style("color") = "red" Message.InnerHtml = ex.message.ToString() Finally fsReadXml.Close() End Try End Sub Sub GetNew(Sender As Object, E As EventArgs) BindGrid() End Sub Sub UseSaved(Sender As Object, E As EventArgs) BindXML() End Sub Sub MyDataGrid_Add(Sender As Object, E As DataGridCommandEventArgs) Connect() myConnection.Open() Dim InsertCmd As String Insertcmd = "INSERT INTO INFOAR(MSGNO, SEVERITY, MSG, KEYWORD) values(@msgno,@sev,@msg,'NONE')" myTxn = myConnection.BeginTransaction() MyCommand = New FbCommand(InsertCmd, MyConnection, myTxn) MyCommand.Parameters.Add("@msgno", FbType.Integer) MyCommand.Parameters("@msgno").Value = E.Item.Cells(6).Text MyCommand.Parameters.Add("@sev", FbType.VarChar, 18) MyCommand.Parameters("@sev").Value = E.Item.Cells(7).Text MyCommand.Parameters.Add("@msg", FbType.VarChar, 250) MyCommand.Parameters("@msg").Value = E.Item.Cells(8).Text Try MyCommand.ExecuteNonQuery() myTxn.Commit() myTxn.Dispose() myCommand.Dispose() Message.Style("color") = "Green" Message.InnerHtml = "<b>Record has been Added.</b><br>" Message2.Style("color") = "green" Message2.InnerHtml = "Matching Records = " & myDataGrid.Items.Count myConnection.Close() Catch Exp As FbException myTxn.Rollback() myTxn.Dispose() myCommand.Dispose() Message.Style("color") = "red" Message.InnerHtml = Exp.Message myConnection.Close() End Try End Sub Hope this is of help. Regards, Andrew Goodall. |
From: Carlos G. A. <car...@te...> - 2003-06-21 09:20:13
Attachments:
VBNETExample.aspx
|
Hello: > Here's and undate to the examples I gave with the html section and some > comments: > > Here's some examples in VB one for a reader, a dataadapter, and a > ExecuteNonQuery. I save the result to an xml file that I can use later > instead of pounding the database with more queries. Note on the > ExecuteNonQuery you have to have a Commit to get it to work unlike SQL > Client or OleDb Client. Attached to this email is a modified version of your sample ( nice sample !! ) that works with the EMPLOYEE.GDB database that ships with Firebird i'm going to add it to the CVS :D, thanks very much -- Best regards Carlos Guzmán Álvarez Vigo-Spain |
From: Alan M. <al...@me...> - 2003-06-21 09:51:46
|
Carlos, Does the gds client incorporated into the provider support custom port numbers for the connection? Alan |
From: Carlos G. A. <car...@te...> - 2003-06-21 10:05:58
|
Hello: > Does the gds client incorporated into the provider support custom port > numbers for the connection? Yes you can specify one in the connection string, iusing the Port element: string connectionString = "User=SYSDBA;" + "Password=masterkey;" + @"Database=EMPLOYEE.GDB;" + "DataSource=localhost;" + "Port=3060;" + <-------------- "Dialect=3;" + "Charset=NONE;" + "Role=;" + "Connection lifetime=15;" + "Pooling=false;" + "Packet Size=8192"; -- Best regards Carlos Guzmán Álvarez Vigo-Spain |
From: Alan M. <al...@me...> - 2003-06-21 10:10:47
|
Yeh thanks - I had to make sure, I have two servers on the same box -= wanted to know which one was actually responding. Alan > -----Original Message----- > From: fir...@li... > [mailto:fir...@li...]On Behalf= Of > Carlos Guzman Alvarez > Sent: Saturday, 21 June 2003 8:06 PM > To: Alan McDonald > Cc: Firebird .Net Provider > Subject: Re: [Firebird-net-provider] where to get .net provider and > examples > > > Hello: > > > Does the gds client incorporated into the provider support custom= port > > numbers for the connection? > > > Yes you can specify one in the connection string, iusing the Port e= lement: > > string connectionString =3D > =09"User=3DSYSDBA;"=09=09=09+ > =09"Password=3Dmasterkey;"=09=09+ > =09@"Database=3DEMPLOYEE.GDB;" =09+ > =09"DataSource=3Dlocalhost;"=09=09+ > =09"Port=3D3060;"=09=09=09+=09<-------------- > =09"Dialect=3D3;"=09=09=09+ > =09"Charset=3DNONE;"=09=09=09+ > =09"Role=3D;"=09=09=09+ > =09"Connection lifetime=3D15;"=09+ > =09"Pooling=3Dfalse;"=09=09+ > =09"Packet Size=3D8192"; > > > > > > -- > Best regards > > Carlos Guzm=E1n =C1lvarez > Vigo-Spain > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: INetU > Attention Web Developers & Consultants: Become An INetU Hosting Par= tner. > Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commis= sion! > INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.= php > _______________________________________________ > Firebird-net-provider mailing list > Fir...@li... > https://lists.sourceforge.net/lists/listinfo/firebird-net-provider > |
From: Carlos G. A. <car...@te...> - 2003-06-20 14:28:21
|
Hello: > Here's some examples in VB one for a reader, a dataadapter, and a > ExecuteNonQuery. I save the result to an xml file that I can use later > instead of pounding the database with more queries. Note on the > ExecuteNonQuery you have to have a Commit to get it to work unlike SQL > Client or OleDb Client. Can I add these VB.NET samples to the Firebird .NET Data Provider distribution ?? :D -- Best regards Carlos Guzmán Álvarez Vigo-Spain |