Recently, I stumbled upon request to show data source property from Connection String to the end user. While, we can always split and parse the values, I was wondering about easy options for this and found 'OledbConnectionStringBuilder' class (Similar class available for SQL too)
To find Connection String parameters, just use it one of its method as below
return new OledbConnectionStringBuilder(ConnectionString).DataSource;
Simple and effective way to get the value..
Friday, 16 March 2012
Saturday, 6 August 2011
Restore Windows State from minimized to previous state
To restore windows state from minimized to previous state, use the following
SendMessage(docView.Handle, WM_SYSCOMMAND, SC_RESTORE, 0);
SendMessage(docView.Handle, WM_SYSCOMMAND, SC_RESTORE, 0);
Saturday, 25 June 2011
How to configure the Store to Database option in IRD
Here is what to do:
1. Run Sql script against configuration Database. ird_create_tables_sql
2. Created a New DBServer Application in CME
3. Installed DB Server (As a Client of Configuration server)
4. Created New Database Access Point, which uses new DBServer
5. In IR Designer I made a connection to the Database Access Point
6. Database access Point needs to point to the Configuration Database (Or where you ran the Script)
NOTE:
You do not have to create a New DBServer, you can use the existing one.
Thursday, 23 June 2011
How to: Change an Assembly Name (Visual Basic, C#)
The Assembly Name property of an application determines the name that will be used for the compiled application. For example, setting the Assembly Name to "MyApplication" for a Windows-based application would result in an executable file named MyApplication.exe. The Assembly Name defaults to the project name; it can be changed on the Application page of the Project Designer.
http://msdn.microsoft.com/en-us/library/f0c12ze9.aspx
To change the Assembly Name property
- With a project selected in Solution Explorer, on the Project menu, click Properties.
- Click the Application tab.
- In the Assembly Name field, type the name for your application.
Note |
---|
Although the default value of the Assembly Name is the same as the project name, the two are unrelated; changing the project name does not change the Assembly Name and changing the Assembly Name does not change the project name. |
http://msdn.microsoft.com/en-us/library/f0c12ze9.aspx
Wednesday, 22 June 2011
Get Last Modified File from Folder
Here is sample code to get last modified file from folder
Dim directory As DirectoryInfo = New DirectoryInfo("C:\Temp")
Dim filter As String = txtFileName.Text
If directory.GetFiles(txtFileName.Text).Count > 0 Then
Dim myFile As FileInfo = directory.GetFiles(filter).OrderByDescending(Function(f) f.LastWriteTime).First()
MsgBox(myFile.Name)
Else
MsgBox("No files found")
End If
Dim directory As DirectoryInfo = New DirectoryInfo("C:\Temp")
Dim filter As String = txtFileName.Text
If directory.GetFiles(txtFileName.Text).Count > 0 Then
Dim myFile As FileInfo = directory.GetFiles(filter).OrderByDescending(Function(f) f.LastWriteTime).First()
MsgBox(myFile.Name)
Else
MsgBox("No files found")
End If
Monday, 20 June 2011
Best way to convert seconds into (Hour:Minutes:Seconds:Milliseconds) time?
Just use the TimeSpan class.
TimeSpan t = TimeSpan.FromSeconds(secs);
string answer = string.Format("{0:D2}h:{1:D2}m:{2:D2}s:{3:D3}ms",
t.Hours,
t.Minutes,
t.Seconds,
t.Milliseconds);
Wednesday, 1 June 2011
Outbound : Convert seconds to UTC Time and vice versa
To convert date from export file to seconds passed after 01/01/1970 in Genesys format)
Dim sDate As String = "01/06/2011 16:46:44"
Dim date1 As Date = #1/1/1970#
Dim date2 As Date = DateTime.Parse(sDate).ToUniversalTime
inSeconds = DateDiff("s", date1, date2))
To convert seconds from database to date and time
Dim localTime As Date
Dim date1 As Date = #1/1/1970#
localTime = date1.AddSeconds(1306943204).ToLocalTime
Debug.Print localtime.ToString
Dim sDate As String = "01/06/2011 16:46:44"
Dim date1 As Date = #1/1/1970#
Dim date2 As Date = DateTime.Parse(sDate).ToUniversalTime
inSeconds = DateDiff("s", date1, date2))
To convert seconds from database to date and time
Dim localTime As Date
Dim date1 As Date = #1/1/1970#
localTime = date1.AddSeconds(1306943204).ToLocalTime
Debug.Print localtime.ToString
Subscribe to:
Posts (Atom)