How Set Time Format in SSRS Report


Formatting – 1: 

Let your expression be as it is coming from inside AX. Don't change it. Revert back everything to same as it was giving you time.
Next, right click your textbox and click textbox properties. Finally click on Number and change formatting there.
If you will copy formatting expression, as value, you will get "expression as value". 

Part 1:
First simply drag your field on design of SSRS. Don’t do anything with formatting. Let it display data, which is coming from AX. 

Part 2:
Now, when you are sure that data is coming on Report, and it just matter of formatting left, right click your textbox and click textbox properties. Finally click on Number and change formatting there.

Formatting – 2: 

=Format(TimeSerial(0,0,Fields!starttime.Value),"hh:mm:ss tt") - 12 hour clock
=Format(TimeSerial(0,0,Fields!starttime.Value),"HH:mm:ss tt") - 24 hour clock
=Format(TimeSerial(0,0,Fields!FromTime.Value),"hh:mm tt") 

As you can change Hours, Minutes, Seconds as per requirements in your SSRS Report.
How to close a form using X++

How to close a form using X++

There are "only" 5 ways to close a form:

Close              - close the form. Similar to the 'X' button.
CloseOK             close the form, and set the OK flag  called by the Commandbutton::Ok
CloseCancel         close the form, and set the Cancel flag  called by the Commandbutton::Cancel
CloseSelectRecord   close the lookup form, and set return record
CloseSelect         close the lookup form, and set return value

The below methods (note their names are in past-tense) are used to determine if or how a form was closed:

Closed         Returns true, if the form is no longer open
ClosedOK       Return true, if the form was closed by the user clicking OK
ClosedCancel   Returns true, if the form was closed by the user clicking Cancel

Finally, CanClose() is called before any of the close methods get called. If CanClose() returns false, the form is not allowed to close.

How to take Backup of Perticular user Customization n in Ax 2012

Description:-

In this Example we will see how to take particular user Customization Backup in Shared Project in Ax 2012. And you can take Backup in User wise Also.

First Create New Shared Project form Ax action Pane tab.

Open it in New Window by right clicking on that Project. Now select Advance Filter Option from Project.


Then Project filter window will open and from that window select Per User for take User wise Customization Backup from AOT or else you can select user wise also first select Per User for take User wise Customization Backup.

After click on Select button for select what data you want to take from AOT. Inquiry Window will open.

Now Click OK and from Project Filter Window Click OK.

After that take time for taking all User Creation from That Project. And after Message Window will open for Complete Backup there you can see Customization.

After when you open your Shared Project there you can see all User Wise CustomizationBackup on that Project.

 
How to Display Header information in SSRS Report

How to Display Header information in SSRS Report

Description:-

In my one of project I required like below information in header Fromdate, Todate, Report run date and Page no out of total pages.

Copy paste below code and change your fields and Changes in Textbox Properties like HTML formatting.
For that Select your Textbox inside Expression and right click on it and go to Textbox property ON General Tab There are to Radio button one for Text and another for HTML Content Select HTML text. After that run your report and you will get.

="From Date : " & Format(Fields!FromDate.Value, "dd/MM/yyyy") & "<br>" &
"To Date : " & Format(Fields!ToDate.Value, "dd/MM/yyyy") & "<br>" &
"Report Run Date : " & FORMAT(Now(),"dd/MM/yyyy hh:mm:ss tt") & "<br>" &
"Page "&Globals!PageNumber &" of "&Globals!TotalPages 

Output : 

From Date : 01\01\2017
To Date : 01\01\2017
Report Run Date : 01\01\012017 12:00:00 PM
Page 1 of 2 

Note: My recommendation please set Text alignment to Right so you will batter format in Preview.
Change Form Contrl through class in Ax 2012

Change Form Contrl through class in Ax 2012

Description:-

In my one of project I need to changes form controls through class. Here is the solution to change the form controls through class in Ax 2012.

First of all table the table, form and classes name like below I have given for demonstration.
  • Form Name: - Form1
  • Table Name: - Table1, Table2
  • Class Name: - Class1
In Table1 I have some fields like ItemId to modify and get the dimension value for that selected ItemId.
So in Form1 Generate the Modified Method for that Field and code call the Class1.
Declare the Class1 and Call the Class1 and Pass the Table1 as parameter. In Class1 I have created GetInventDim Method.
Class1 Class1;
Class1 = new Class1();
Class1.GetInventDim(Table1);

In Class1 Code for Enable\Disable Control Logic.
Declare the following Classes in Class Declaration.
FormComboBoxControl   formComboBoxControl;
Common                             externalRecord;
FormDataSource               frmDs;
FormRun                            formRun;
FormControl                      frmCtrl;

After in GetInventDim Method.

if(_trans.isFormDataSource())
{
  frmDs = _trans.dataSource();
  formRun = frmDs.formRun();
  if(formRun)
  {
     formComboBoxControl = formRun.design().controlName (formControlStr (Table1, Form1_ControlId));
     if(formComboBoxControl)
     {
       formComboBoxControl.text(" ");
       formComboBoxControl.allowEdit(false);
     }
  }
}

Html markup in Gridview in asp.net


Description:-

Here first we add a Gridview control, by just drag and drop on our web page. Now will use item template to display data .i.e (we are are going to show employee name, gender, location, and department).

Now we want to edit the department for selected employee. So now we added a drop-down list under edit template, which will display only on edit mode. Our final HTML looks like as written below.

Default.aspx:-

    <div>
        <asp:GridView ID="gv" runat="server" AutoGenerateColumns="False" OnRowCancelingEdit="gv_RowCancelingEdit"
            OnRowEditing="gv_RowEditing" OnRowDataBound="gv_RowDataBound">
            <Columns>
                <asp:TemplateField HeaderText="Name">
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Eval("Name") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Gender">
                    <ItemTemplate>
                        <asp:Label ID="Label2" runat="server" Text='<%# Eval("Gender") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Location">
                    <ItemTemplate>
                        <asp:Label ID="Label3" runat="server" Text='<%# Eval("Location") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Department">
                    <EditItemTemplate>
                        <asp:DropDownList ID="ddl_department" runat="server">
                        </asp:DropDownList>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label4" runat="server" Text='<%# Eval("department_name") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField ShowHeader="False">
                    <EditItemTemplate>
                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update"
                            Text="Update"></asp:LinkButton>
                        <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel"
                            Text="Cancel"></asp:LinkButton>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
                            Text="Edit"></asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
    </div>
 

How to Count Number of Ticks using X++ in AX

How to Count Number of Ticks using X++ in AX

Measure execution time of your code

Retrieves the number of milliseconds that have elapsed since the system was started, up to 49.7 days.

Measuring is knowing. Before you start changing code, make sure you have a set of data you can keep reusing for your tests. Measure the performance of your code on that data after each change in code so you know the impact of your changes. 

One way to do this is by using the Winapi::getTickCount() (or WinApiServer::getTickCount() if your code runs on server) method.

static void TickCountExample(Args _args)
{
    int ticks;
    ;
    // get the tickcount before the process starts
    ticks = winapi::getTickCount();   
    // start the process
    sleep(2000); // simulate 2 seconds of processing  
    // compare tickcount
    ticks = winapi::getTickCount() - ticks;  
    // display result
    info(strfmt('Number of ticks: %1', ticks));
}


DataBase Connection String


Description:- 

a connection string is a string that specifies information about a data source and the means of connecting to it. It is passed in code to an underlying driver or provider in order to initiate the connection.

When your application connects to a database or a data file you let ADO or ADO.Net utilize a provider to do the job for you. The connection string contains the information that the provider need to know to be able to establish a connection to the database or the data file.

Because there are different providers and each providers have multiple ways to make a connection there are many different ways to write a connection string. It's like the address when sending a regular mail. Depending on the origin and destination and who is going to make the transport you need to write down the address in different ways.

For example; the provider needs the address to the server (or the path to the data file) to connect to. This parameter is often named "Server" or "Data Source". The value specified for this key in the connection string is passed on to the provider and this is how it’s possible for the provider to know where to connect.

There are some basic rules on how to format the information needed for the connection to take place. The way we represent the configuration values inside of the connection string. As it is a string, there are no data types, it's all string values but they have to be correctly coded so the drivers can read it properly.
 

Microsoft SQL Server

ODBC DSN
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.                "Dsn=DsnName;" +
5.                "Uid=UserName;" +
6.                "Pwd=Secret;";
7.  conn.Open();
ODBC -- Standard Connection
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.                "Driver={SQL Server};" +
5.                "Server=DataBaseNamex;" +
6.                "DataBase=DataBaseName;" +
7.                "Uid=UserName;" +
8.                "Pwd=Secret;";
9.  conn.Open();
ODBC -- Trusted Connection
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.                "Driver={SQL Server};" +
5.                "Server=ServerName;" +
6.                "DataBase=DataBaseName;" +
7.                "Uid=;" +
8.                "Pwd=;";
9.  conn.Open();
10.// or
11.var conn = new OdbcConnection();
12.conn.ConnectionString =
13.              "Driver={SQL Server};" +
14.              "Server=ServerName;" +
15.              "DataBase=DataBaseName;" +
16.              "Trusted_Connection=Yes;";
17.conn.Open();
OleDb -- Standard Connection
1.  using System.Data.OleDb;
2.  var conn = new OleDbConnection();
3.  conn.ConnectionString =
4.                "Driver=SQLOLEDB;" +
5.                "Data Source=ServerName;" +
6.                "Initial Catalog=DataBaseName;" +
7.                "User id=UserName;" +
8.                "Password=Secret;";
9.  conn.Open();
OleDb -- Trusted Connection
1.  using System.Data.OleDb;
2.  var conn = new OleDbConnection();
3.  conn.ConnectionString =
4.                "Driver=SQLOLEDB;" +
5.                "Data Source=ServerName;" +
6.                "Initial Catalog=DataBaseName;" +
7.                "Integrated Security=SSPI;";
8.  conn.Open();
OleDb -- via IP Address
1.  using System.Data.OleDb;
2.  var conn = new OleDbConnection();
3.  conn.ConnectionString =
4.                "Driver=SQLOLEDB;" +
5.                "Network Library=DBMSSOCN;" +
6.                "Data Source=xxx.xxx.xxx.xxx,1433;" +
7.                "Initial Catalog=DataBaseName;" +
8.                "User id=UserName;" +
9.                "Password=Secret;";
10.conn.Open();
.NET DataProvider -- Standard Connection
1.  using System.Data.SqlClient;
2.  var conn = new SqlDbConnection();
3.  conn.ConnectionString =
4.                "Data Source=ServerName;" +
5.                "Initial Catalog=DataBaseName;" +
6.                "User id=UserName;" +
7.                "Password=Secret;";
8.  conn.Open();
.NET DataProvider -- Trusted Connection
1.  using System.Data.SqlClient;
2.  var conn = new SqlConnection();
3.  conn.ConnectionString =
4.                "Data Source=ServerName;" +
5.                "Initial Catalog=DataBaseName;" +
6.                "Integrated Security=SSPI;";
7.  conn.Open();
.NET DataProvider -- via IP Address
1.  using System.Data.SqlClient;
2.  var conn = new SqlConnection();
3.  conn.ConnectionString =
4.                "Network Library=DBMSSOCN;" +
5.                "Data Source=xxx.xxx.xxx.xxx,1433;" +
6.                "Initial Catalog=DataBaseName;" +
7.                "User Id=UserName;" +
8.                "Password=Secret;";
9.  conn.Open();



Microsoft Sql Express
.NET Data Provider -- Default Relative Path -- Standard Connection
1.  using System.Data.SqlClient;
2.  var conn = new SqlConnection();
3.  conn.ConnectionString =
4.       "Data Source=.\SQLExpress;" +
5.       "User Instance=true;" +
6.       "User Id=UserName;" +
7.       "Password=Secret;" +
8.       "AttachDbFilename=|DataDirectory|DataBaseName.mdf;"
9.  conn.Open();
.NET Data Provider -- Default Relative Path -- Trusted Connection
1.  using System.Data.SqlClient;
2.  var conn = new SqlConnection();
3.  conn.ConnectionString =
4.       "Data Source=.\SQLExpress;" +
5.       "User Instance=true;" +
6.       "Integrated Security=true;" +
7.       "AttachDbFilename=|DataDirectory|DataBaseName.mdf;"
8.  conn.Open();
.NET Data Provider -- Custom Relative Path -- Standard Connection
1.  using System.Data.SqlClient;
2.  AppDomain.CurrentDomain.SetData(
3.       "DataDirectory", "C:\MyPath\");
4.  var conn = new SqlConnection();
5.  conn.ConnectionString =
6.       "Data Source=.\SQLExpress;" +
7.       "User Instance=true;" +
8.       "User Id=UserName;" +
9.       "Password=Secret;" +
10.     "AttachDbFilename=|DataDirectory|DataBaseName.mdf;"
11.conn.Open();
.NET Data Provider -- Custom Relative Path -- Trusted Connection
1.  using System.Data.SqlClient;
2.  AppDomain.CurrentDomain.SetData(
3.       "DataDirectory", "C:\MyPath\");
4.  var conn = new SqlConnection();
5.  conn.ConnectionString =
6.       "Data Source=.\SQLExpress;" +
7.       "User Instance=true;" +
8.       "Integrated Security=true;" +
9.       "AttachDbFilename=|DataDirectory|DataBaseName.mdf;"
10.conn.Open();
.NET Data Provider -- Absolute Path -- Standard Connection
1.  using System.Data.SqlClient;
2.  var conn = new SqlConnection();
3.  conn.ConnectionString =
4.       "Data Source=.\SQLExpress;" +
5.       "User Instance=true;" +
6.       "User Id=UserName;" +
7.       "Password=Secret;" +
8.       "AttachDbFilename=C:\MyPath\DataBaseName.mdf;"
9.  conn.Open();
.NET Data Provider -- Absolute Path -- Trusted Connection
1.  using System.Data.SqlClient;
2.  var conn = new SqlConnection();
3.  conn.ConnectionString =
4.       "Data Source=.\SQLExpress;" +
5.       "User Instance=true;" +
6.       "Integrated Security=true;" +
7.       "AttachDbFilename=C:\MyPath\DataBaseName.mdf;"
8.  conn.Open();



Microsoft Access
ODBC DSN
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString = "Dsn=DsnName";
4.  conn.Open();
ODBC -- Standard Security
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.      "Driver={Microsoft Access Driver (*.mdb)};" +
5.      "Dbq=c:\myPath\myDb.mdb;" +
6.      "Uid=Admin;Pwd=;";
7.  conn.Open();
ODBC -- Workgroup (System Database)
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.      "Driver={Microsoft Access Driver (*.mdb)};" +
5.      "Dbq=c:\myPath\myDb.mdb;" +
6.      "SystemDb=c:\myPath\myDb.mdw;";
7.  conn.Open();
ODBC -- Exclusive Use
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.       "Driver={Microsoft Access Driver (*.mdb)};" +
5.       "Dbq=c:\myPath\myDb.mdb;" +
6.       "Exclusive=1;";
7.       "Uid=Admin;Pwd=;";
8.  conn.Open();
OleDb with MS Jet -- Standard Security
1.  using System.Data.OleDb;
2.  var conn = new OleDbConnection();
3.  conn.ConnectionString =
4.             "Provider=Microsoft.Jet.OLEDB.4.0;" +
5.             "Data Source=c:\mypath\myDb.mdb;" +
6.             "User id=admin;" +
7.             "Password=";
8.  conn.Open();
OleDb with MS Jet -- Workgroup (System Database)
1.  using System.Data.OleDb;
2.  var conn = new OleDbConnection();
3.  conn.ConnectionString =
4.             "Provider=Microsoft.Jet.OLEDB.4.0;" +
5.             "Data Source=c:\mypath\myDb.mdb;" +
6.             "System Database=c:\mypath\myDb.mdw;";
7.  conn.Open();
OleDb with MS Jet -- With Password
1.  using System.Data.OleDb;
2.  var conn = new OleDbConnection();
3.  conn.ConnectionString =
4.             "Provider=Microsoft.Jet.OLEDB.4.0;" +
5.             "Data Source=c:\mypath\myDb.mdb;" +
6.             "Database Password=Secret;"
7.  conn.Open();



Oracle

ODBC DSN
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.                "Dsn=DsnName;" +
5.                "Uid=UserName;" +
6.                "Pwd=Secret;";
7.  conn.Open();
ODBC -- New Microsoft Driver
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.             "Driver={Microsoft ODBC for Oracle};" +
5.             "Server=OracleServer.world;" +
6.             "Uid=UserName;" +
7.             "Pwd=Secret;";
8.  conn.Open();
ODBC -- Old Microsoft Driver
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.      "Driver={Microsoft ODBC Driver for Oracle};" +
5.      "ConnectString=OracleServer.world;" +
6.      "Uid=UserName;" +
7.      "Pwd=Secret;";
8.  conn.Open();
ODBC -- Oracle Driver
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.      "Driver={Oracle ODBC Driver};" +
5.      "Dbq=myDataBase;" + // define in tsnames.ora
6.      "Uid=UserName;" +
7.      "Pwd=Secret;";
8.  conn.Open();
OleDb -- Microsoft Driver
1.  uusing System.Data.OleDb;
2.  var conn = new OleDbConnection();
3.  conn.ConnectionString =
4.                "Driver=MSDAORA;" +
5.                "Data Source=ServerName;" +
6.                "User id=UserName;" +
7.                "Password=Secret;";
8.  conn.Open();
OleDb -- Oracle Driver -- Standard Connection
1.  using System.Data.OleDb;
2.  var conn = new OleDbConnection();
3.  conn.ConnectionString =
4.                "Driver=OraOLEDB.Oracle;" +
5.                "Data Source=ServerName;" +
6.                "User id=UserName;" +
7.                "Password=Secret;";
8.  conn.Open();
OleDb -- Oracle Driver -- Trusted Connection
1.  using System.Data.OleDb;
2.  var conn = new OleDbConnection();
3.  conn.ConnectionString =
4.                "Driver=OraOLEDB.Oracle;" +
5.                "Data Source=ServerName;" +
6.                "OSAuthent=1;";
7.  conn.Open();
8.  // or
9.  using System.Data.OleDb;
10.var conn = new OleDbConnection();
11.conn.ConnectionString =
12.              "Driver=OraOLEDB.Oracle;" +
13.              "Data Source=ServerName;" +
14.              "User id=/" +
15.              "Password=;";
16.conn.Open();
.NET DataProvider from Microsoft -- Standard Connection
1.  using System.Data.OracleClient;
2.  var conn = new OracleConnection();
3.  conn.ConnectionString =
4.                "Data Source=ServerName;" +
5.                "User id=UserName;";
6.                "Password=Secret;";
7.  conn.Open();
.NET DataProvider from Microsoft -- Trusted Connection
1.  using System.Data.OracleClient;
2.  var conn = new OracleConnection();
3.  conn.ConnectionString =
4.                "Data Source=Servername;" +
5.                "Integrated Security=Yes;";
6.  conn.Open();
.NET DataProvider from Oracle -- Standard Connection
1.  using Oracle.DataAccess.Client;
2.  var conn = new OracleConnection();
3.  conn.ConnectionString =
4.                "Data Source=ServerName;" +
5.                "User id=UserName;";
6.                "Password=Secret;";
7.  conn.Open();
.NET DataProvider from Oracle -- Trusted Connection
1.  using Oracle.DataAccess.Client;
2.  var conn = new OracleConnection();
3.  conn.ConnectionString =
4.                "Data Source=Servername;" +
5.                "Integrated Security=Yes;";
6.  conn.Open();



IBM DB2
ODBC DSN
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.                "Dsn=DsnName;" +
5.                "Uid=UserName;" +
6.                "Pwd=Secret;";
7.  conn.Open();
ODBC without DSN
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.                "Driver={IBM DB2 ODBC DRIVER};" +
5.                "DataBase=DataBaseName;" +
6.                "HostName=ServerName;" +
7.                "Protocol=TCPIP;" +
8.                "Port=PortNumber;" +
9.                "Uid=UserName;" +
10.              "Pwd=Secret;";
11.conn.Open();
OleDb -- Microsoft Driver
1.  using System.Data.OleDb;
2.  var conn = new OleDbConnection();
3.  conn.ConnectionString =
4.             "Driver=DB2OLEDB;" +
5.             "Network Transport Library=TCPIP;" +
6.             "Network Address=xxx.xxx.xxx.xxx;" +
7.             "Package Collection=CollectionName;" +
8.             "Initial Catalog=DataBaseName;" +
9.             "User id=UserName;" +
10.           "Password=Secret;";
11.conn.Open();
OleDb -- IBM Driver
1.  using System.Data.OleDb;
2.  var conn = new OleDbConnection();
3.  conn.ConnectionString =
4.              "Driver=IBMDADB2;" +
5.              "DataBase=DataBaseName;" +
6.              "HostName=ServerName;" +
7.              "Protocol=TCPIP;" +
8.              "Port=PortNumber;" +
9.              "Uid=UserName;" +
10.            "Pwd=Secret;";
11.conn.Open();
.NET DataProvider from IBM
1.  using IBM.Data.DB2;
2.  var conn = new Db2Connection();
3.  conn.ConnectionString =
4.                "DataBase=DataBaseName;" +
5.                "Uid=UserName;" +
6.                "Pwd=Secret;" +
7.  conn.Open();



MySql
ODBC DSN
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.                "Dsn=DsnName;" +
5.                "Uid=UserName;" +
6.                "Pwd=Secret;";
7.  conn.Open();
ODBC -- MyODBC Driver -- local database
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.              "Driver={MySql};" +
5.              "Server=localhost;" +
6.              "Option=16834;" +
7.              "DataBase=DataBaseName;"
8.  conn.Open();
ODBC -- MyODBC Driver -- remote database
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.              "Driver={MySql};" +
5.              "Server=db.domain.com;" +
6.              "Option=131072;" +
7.              "Port=3306;" +
8.              "Stmt=;" +
9.              "DataBase=DataBaseName;" +
10.            "Uid=UserName;" +
11.            "Pwd=Secret;"
12.conn.Open();
ODBC -- MySQL ODBC 3.51 Driver
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.       "Driver={MySql ODBC 3.51 Driver};" +
5.       "Server=ServerName;" +
6.       "Option=16834;" +
7.       "Port=3306;" +
8.       "Stmt=;" +
9.       "DataBase=DataBaseName;" +
10.     "Uid=UserName;" +
11.     "Pwd=Secret;"
12.conn.Open();
13.// or
14.var conn = new OdbcConnection();
15.conn.ConnectionString =
16.     "DRIVER={MySql ODBC 3.51 Driver};" +
17.     "SERVER=ServerName;" +
18.     "DATABASE=DataBaseName;" +
19.     "USER=UserName;" +
20.     "PASSWORD=Secret;"
21.conn.Open();
OleDb
1.  using System.Data.OleDb;
2.  var conn = new OleDbConnection();
3.  conn.ConnectionString =
4.              "Provider=MySqlProv;" +
5.              "Data Source=ServerName;" +
6.              "User id=UserName;" +
7.              "Password=Secret;"
8.  conn.Open();
.NET DataProvider from CoreLab
1.  using CoreLab.MySql;
2.  var conn = new MySqlConnection();
3.  conn.ConnectionString =
4.                "Host=ServerName;" +
5.                "DataBase=DataBaseName;" +
6.                "Protocol=TCP;" +
7.                "Port=3306;" +
8.                "Direct=true;" +
9.                "Compress=false;" +
10.              "Pooling=true;" +
11.              "Min Pool Size=0;" +
12.              "Max Pool Size=100;" +
13.              "Connection Lifetime=0;" +
14.              "User id=UserName;" +
15.              "Password=Secret;" +
16.conn.Open();



Sybase
ODBC DSN
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.                "Dsn=DsnName;" +
5.                "Uid=UserName;" +
6.                "Pwd=Secret;";
7.  conn.Open();
ODBC -- Sybase System 12 (12.5) ODBC Driver
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.                "Driver={SYBASE ASE ODBC Driver};" +
5.                "Srvr=ServerName;" +
6.                "Uid=UserName;" +
7.                "Pwd=Secret;";
8.  conn.Open();
ODBC -- Sybase System 11 ODBC Driver
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.             "Driver={SYBASE SYSTEM 11};" +
5.             "Srvr=ServerName;" +
6.             "Uid=UserName;" +
7.             "Pwd=Secret;";
8.  conn.Open();
ODBC -- Intersolv 3.10 ODBC Driver
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.          "Driver={INTERSOLV 3.10 32-BIT Sybase};" +
5.          "Srvr=ServerName;" +
6.          "Uid=UserName;" +
7.          "Pwd=Secret;";
8.  conn.Open();
ODBC -- SQL Anywhere
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.           "ODBC;" +
5.           "Driver={Sybase SQL Anywhere 5.0};" +
6.           "DefaultDir=c:\myfolder\;" +
7.           "Dbf=c:\mypath\dbname.db;" +
8.           "Uid=UserName;" +
9.           "Pwd=Secret;" +
10.         "Dsn="""";";     // Must be included!
11.conn.Open();
OleDb -- Sybase Adaptive Server Enterprise (ASE)
1.  using System.Data.OleDb;
2.  var conn = new OleDbConnection();
3.  conn.ConnectionString =
4.                "Driver=Sybase.ASEOLEDBProvider;" +
5.                "Server Name=ServerName,5000;" +
6.                "Initial Catalog=DataBaseName;" +
7.                "User id=UserName;" +
8.                "Password=Secret;";
9.  conn.Open();
10.// optionally, replace
11.// 'Server Name' with 'Srvr', and
12.// 'Initial Catalog' with 'Catalog'
.NET DataProvider from Sybase
1.  using Sybase.Data.AseClient;
2.  var conn = new AseConnection();
3.  conn.ConnectionString =
4.                "Data Source=ServerName;" +
5.                "Initial Catalog=DataBaseName;" +
6.                "User id=UserName;" +
7.                "Password=Secret;";
8.  conn.Open();



Interbase
ODBC DSN
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.                "Dsn=DsnName;" +
5.                "Uid=UserName;" +
6.                "Pwd=Secret;";
7.  conn.Open();
ODBC -- EasySoft ODBC Driver -- local machine
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.        "Driver={Easysoft IB6 ODBC};" +
5.        "Server=localhost;" +
6.        "DataBase=localhost:C:\MyPath\DbName.gdb;" +
7.        "Uid=UserName;" +
8.        "Pwd=Secret;";
9.  conn.Open();
ODBC -- EasySoft ODBC Driver -- remote machine
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.        "Driver={Easysoft IB6 ODBC};" +
5.        "Server=ServerName;" +
6.        "DataBase=ServerName:C:\MyPath\DbName.gdb;" +
7.        "Uid=UserName;" +
8.        "Pwd=Secret;";
9.  conn.Open();
ODBC -- Intersolv ODBC Driver -- local machine
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.        "Driver=" +
5.     "{INTERSOLV InterBase ODBC Driver (*.gdb)};" +
6.        "Server=localhost;" +
7.        "DataBase=localhost:C:\MyPath\DbName.gdb;" +
8.        "Uid=UserName;" +
9.        "Pwd=Secret;";
10.conn.Open();
ODBC -- Intersolv ODBC Driver -- remote machine
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.        "Driver=" +
5.     "{INTERSOLV InterBase ODBC Driver (*.gdb)};" +
6.        "Server=ServerName;" +
7.        "DataBase=ServerName:C:\MyPath\DbName.gdb;" +
8.        "Uid=UserName;" +
9.        "Pwd=Secret;";
10.conn.Open();



Informix
ODBC DSN -- INFORMIX 3.30 ODBC Driver
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.                "Dsn=DsnName;" +
5.                "Host=HostName;" +
6.                "Server=ServerName;" +
7.                "Service=ServerName;" +
8.                "Protocol=olsoctcp;" +
9.                "Database=DataBaseName;" +
10.              "Uid=UserName;" +
11.              "Pwd=Secret;";
12.conn.Open();
ODBC without DSN -- INFORMIX 3.30 ODBC Driver
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.                "Dsn="";" +
5.                "Driver={INFORMIX 3.30 32 BIT};" +
6.                "Host=HostName;" +
7.                "Server=ServerName;" +
8.                "Service=ServerName;" +
9.                "Protocol=olsoctcp;" +
10.              "Database=DataBaseName;" +
11.              "Uid=UserName;" +
12.              "Pwd=Secret;";
13.conn.Open();
ODBC Informix-CLI 2.5 ODBC Driver
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.            "Driver={Informix-CLI 2.5 (32 Bit)};" +
5.            "Server=ServerName;" +
6.            "DataBase=DataBaseName;" +
7.            "Uid=UserName;" +
8.            "Pwd=Secret;";
9.  conn.Open();
OleDb -- IBM Informix OleDb Provider
1.  using System.Data.OleDb;
2.  var conn = new OleDbConnection();
3.  conn.ConnectionString =
4.          "Driver=IFXOLEDBC;" +
5.          "Data Source=DataBaseName@ServerName;" +
6.          "User id=UserName;" +
7.          "Password=Secret;";
8.          "Persist Security Info=true;";
9.  conn.Open();



Excel
ODBC DSN
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.                "Dsn=DsnName;" +
5.                "Uid=UserName;" +
6.                "Pwd=Secret;";
7.  conn.Open();
ODBC without DSN
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.         "Driver={Microsoft Excel Driver (*.xls)};" +
5.         "Driverid=790;" +
6.         "Dbq=C:\MyPath\SpreadSheet.xls;" +
7.         "DefaultDir=C:\MyPath;";
8.  conn.Open();
OleDb with MS Jet
1.  using System.Data.OleDb;
2.  var conn = new OleDbConnection();
3.  conn.ConnectionString =
4.      "Driver=Microsoft.Jet.OLEDB.4.0;" +
5.      "Data Source=C:\MyPath\SpreadSheet.xls;" +
6.     @"Extended Properties=""Excel 8.0;HDR=Yes""";
7.  conn.Open();



Text
ODBC DSN
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.                "Dsn=DsnName;" +
5.                "Uid=UserName;" +
6.                "Pwd=Secret;";
7.  conn.Open();
ODBC without DSN
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.   "Driver={Microsoft Text Driver (*.txt; *.csv)};" +
5.   "Dbq=C:\MyPath\;" +
6.   "Extensions=asc,csv,tab,txt;";
7.  conn.Open();
8.  // Use: sql = "Select * From MyTextFile.txt"
OleDb with MS Jet
1.  using System.Data.OleDb;
2.  var conn = new OleDbConnection();
3.  conn.ConnectionString =
4.        "Driver=Microsoft.Jet.OLEDB.4.0;" +
5.        "Data Source=C:\MyPath\;" +
6.        "Extended Properties=" +
7.          @"""text;HDR=Yes;FMT=Delimited""";
8.  conn.Open();
9.  // Use: sql = "Select * From MyTextFile.txt"



dBase Dbf
ODBC DSN
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString = "Dsn=DsnName";
4.  conn.Open();
5.  // Use: sql = "Select * From MyDb.dbf"
ODBC without DSN
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.       "Driver={Microsoft dBASE Driver (*.dbf)};" +
5.       "Driverid=277;" +
6.       "Dbq=C:\MyPath\";
7.  conn.Open();
8.  // Use: sql = "Select * From MyDb.dbf"



Visual FoxPro
ODBC DSN
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString = "Dsn=DsnName";
4.  conn.Open();
ODBC without DSN -- Database container (dbc)
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.        "Driver={Microsoft Visual FoxPro Driver};" +
5.        "SourceType=DBC;" +
6.        "SourceDB=C:\MyPath\MyDb.dbc;" +
7.        "Exclusive=No";
8.  conn.Open();
ODBC without DSN -- Free table directory
1.  using System.Data.Odbc;
2.  var conn = new OdbcConnection();
3.  conn.ConnectionString =
4.        "Driver={Microsoft Visual FoxPro Driver};" +
5.        "SourceType=DBF;" +
6.        "SourceDB=C:\MyPath;" +
7.        "Exclusive=No";
8.  conn.Open();
OleDb -- Database container (dbc)
1.  using System.Data.OleDb;
2.  var conn = new OleDbConnection();
3.  conn.ConnectionString =
4.                "Driver=VFPOLEDB;" +
5.                "Data Source=C:\MyPath\MyDb.dbc;" +
6.                "Collating Sequence=machine;" +
7.                "Password=Secret;";
8.  conn.Open();
OleDb -- Free table directory
1.  using System.Data.OleDb;
2.  var conn = new OleDbConnection();
3.  conn.ConnectionString =
4.                "Driver=VFPOLEDB;" +
5.                "Data Source=C:\MyPath\;" +
6.                "Collating Sequence=general;" +
7.                "Password=Secret;";
8.  conn.Open();