Click here to Skip to main content
15,912,329 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: How to force Setup project to use prerequisites with older version Pin
rahul.kulshreshtha19-Apr-10 3:35
rahul.kulshreshtha19-Apr-10 3:35 
QuestionLayOut In . Net Pin
SajjadZare17-Apr-10 6:38
SajjadZare17-Apr-10 6:38 
AnswerRe: LayOut In . Net Pin
Abhinav S17-Apr-10 6:48
Abhinav S17-Apr-10 6:48 
AnswerRe: LayOut In . Net Pin
Super Lloyd19-Apr-10 17:22
Super Lloyd19-Apr-10 17:22 
QuestionDatagrid Header Column Image Pin
Member 42789816-Apr-10 14:25
Member 42789816-Apr-10 14:25 
AnswerRe: Datagrid Header Column Image - One way you can do this is to use the CellsPainting event to draw thebitmap Pin
Peace ON16-Apr-10 20:59
Peace ON16-Apr-10 20:59 
GeneralRe: Datagrid Header Column Image - One way you can do this is to use the CellsPainting event to draw thebitmap Pin
Member 42789817-Apr-10 4:54
Member 42789817-Apr-10 4:54 
QuestionOLEDB VS2010 and need of help! Pin
ahulting16-Apr-10 5:24
ahulting16-Apr-10 5:24 
I am confused; I am using VB2010, IBM.iSeries.DB2 on an as400 V5R4. I am trying to establish an OLEDB connection, and return the values from the selected table to a DataGridView. I had one of the admin’s make me file named GARBAGE, in the Rprtaccess catalog. In the past, I have been able to connect via access and an ODBC connection. My project is too big for access, and the SQL middleware we have is clunky and not user friendly. This is a program that will generate the SQL statements, specifically the WHERE: clause and populate the datagrid with the selected criteria. In essence I am making a user friendly striped down program, that has variables that are manipulated by the end user, and the rest, referenced tables and libraries are coded.


Imports System.Data.OleDb<br />
Imports System.Exception<br />
<br />
<br />
<br />
Public Class Form11<br />
<br />
    Public Sub Form11_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
<br />
        If Not String.IsNullOrEmpty("10.0.0.75\rprtaccess\garbage") Then<br />
<br />
            Dim OleDbConn As New OleDbHandler<br />
            Dim dgvOleDb1 As New Object<br />
            Dim ds As DataSet = OleDbConn.GetDataFromOleDb("10.0.0.75\rprtaccess\")<br />
<br />
            Dim OleCm As New OleDbCommand<br />
<br />
<br />
            If ds IsNot Nothing Then<br />
<br />
                Dim table As New DataTable<br />
                table.Locale = System.Globalization.CultureInfo.InvariantCulture<br />
<br />
                OleCm.CommandType = System.Data.CommandType.StoredProcedure<br />
                OleCm.CommandText = "Select Garbage"<br />
                Dim CM As Object = OleCm.CommandText<br />
<br />
<br />
                Dim OleDA As New OleDbDataAdapter()<br />
                ds = CM.SelectCommand.ExecuteReader<br />
<br />
<br />
<br />
                dgvOleDb1 = table.Select<br />
<br />
                dgvOleDb1.DataSource = DataGridViewEditMode.EditProgrammatically<br />
                dgvOleDb1.DataSource = ds.Tables(0)<br />
            End If<br />
        End If<br />
    End Sub<br />
<br />
    Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvOleDb1.CellContentClick<br />
<br />
    End Sub<br />
    Public Sub ShowOleDbException()<br />
        Dim mySelectQuery As String = "SELECT column1 FROM table1"<br />
        Dim myConnection As New OleDbConnection _<br />
           ("Provider=Microsoft.Jet.OLEDB.4.0;DataSource=")<br />
        Dim myCommand As New OleDbCommand(mySelectQuery, myConnection)<br />
<br />
        Try<br />
            myCommand.Connection.Open()<br />
        Catch e As OleDbException<br />
            Dim errorMessages As String<br />
            Dim i As Integer<br />
<br />
            For i = 0 To e.Errors.Count - 1<br />
                errorMessages += "Index #" & i.ToString() & ControlChars.Cr _<br />
                               & "Message: " & e.Errors(i).Message & ControlChars.Cr _<br />
                               & "NativeError: " & e.Errors(i).NativeError & ControlChars.Cr _<br />
                               & "Source: " & e.Errors(i).Source & ControlChars.Cr _<br />
                               & "SQLState: " & e.Errors(i).SQLState & ControlChars.Cr<br />
            Next i<br />
<br />
            Dim log As System.Diagnostics.EventLog = New System.Diagnostics.EventLog()<br />
            log.Source = "My Application"<br />
            log.WriteEntry(errorMessages)<br />
            Console.WriteLine("An exception occurred. Please contact your system administrator.")<br />
        End Try<br />
    End Sub<br />
<br />
End Class



#Region " Import Section"<br />
Imports System<br />
Imports System.Collections.Generic<br />
Imports System.Text<br />
Imports System.Data<br />
Imports System.Data.OleDb<br />
Imports System.Reflection<br />
Imports System.Runtime.InteropServices<br />
Imports Microsoft.Office.Interop<br />
<br />
#End Region<br />
<br />
<br />
<br />
Public Class OleDbHandler<br />
<br />
    ' Return data in dataset from OleDb. '   <br />
    Public Function GetDataFromOleDb(ByVal a_sFilepath As String) As DataSet<br />
        Dim ds As New DataSet()<br />
        Dim oOleDbConnection As OleDbConnection<br />
        Dim sConnString As String = _<br />
            "Provider=IBMDA400.DataSource.1;" & _<br />
            "Data source=10.0.0.75;" ' & _<br />
        '"User Id=myUsername;" & _<br />
        ' "Password=myPassword"<br />
        oOleDbConnection = New OleDb.OleDbConnection(sConnString)<br />
        oOleDbConnection.Open()<br />
<br />
<br />
<br />
        Try<br />
            oOleDbConnection.Open()<br />
        Catch ex As OleDbException<br />
            Console.WriteLine(ex.Message)<br />
        Catch ex As Exception<br />
            Console.WriteLine(ex.Message)<br />
        End Try<br />
<br />
        ' It Represents  data table '<br />
        Dim dt As New System.Data.DataTable()<br />
        dt = oOleDbConnection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, Nothing)<br />
        If dt IsNot Nothing OrElse dt.Rows.Count > 0 Then<br />
            For sheet_count As Integer = 0 To dt.Rows.Count - 1<br />
                Try<br />
                    ' Create Query to get Data from sheet. '<br />
                    Dim sheetname As String = dt.Rows(sheet_count)("table_name").ToString()<br />
                    Dim da As New OleDbDataAdapter("SELECT * FROM [" & sheetname & "]", sConnString)<br />
                    da.Fill(ds, sheetname)<br />
                Catch ex As DataException<br />
                    Console.WriteLine(ex.Message)<br />
                Catch ex As Exception<br />
                    Console.WriteLine(ex.Message)<br />
                End Try<br />
            Next<br />
        End If<br />
        oOleDbConnection.Close()<br />
        Return ds<br />
    End Function<br />
<br />
<br />
Private Function GetDataOleDb(ByVal a_dtData As System.Data.DataTable) As Object(,)<br />
        Dim obj As Object(,) = New Object((a_dtData.Rows.Count + 1) - 1, a_dtData.Columns.Count - 1) {}<br />
<br />
        Try<br />
            For j As Integer = 0 To a_dtData.Columns.Count - 1<br />
                obj(0, j) = a_dtData.Columns(j).Caption<br />
            Next<br />
<br />
            Dim dt As New DateTime()<br />
            Dim sTmpStr As String = String.Empty<br />
<br />
            For i As Integer = 1 To a_dtData.Rows.Count<br />
                For j As Integer = 0 To a_dtData.Columns.Count - 1<br />
                    If a_dtData.Columns(j).DataType Is dt.[GetType]() Then<br />
                        If a_dtData.Rows(i - 1)(j) IsNot DBNull.Value Then<br />
                            DateTime.TryParse(a_dtData.Rows(i - 1)(j).ToString(), dt)<br />
                            obj(i, j) = dt.ToString("MM/dd/yy hh:mm tt")<br />
                        Else<br />
                            obj(i, j) = a_dtData.Rows(i - 1)(j)<br />
                        End If<br />
                    ElseIf a_dtData.Columns(j).DataType Is sTmpStr.[GetType]() Then<br />
                        If a_dtData.Rows(i - 1)(j) IsNot DBNull.Value Then<br />
                            sTmpStr = a_dtData.Rows(i - 1)(j).ToString().Replace(vbCr, "")<br />
                            obj(i, j) = sTmpStr<br />
                        Else<br />
                            obj(i, j) = a_dtData.Rows(i - 1)(j)<br />
                        End If<br />
                    Else<br />
                        obj(i, j) = a_dtData.Rows(i - 1)(j)<br />
                    End If<br />
<br />
                Next<br />
            Next<br />
        Catch ex As Exception<br />
            Console.WriteLine(ex.Message)<br />
        End Try<br />
        Return obj<br />
    End Function<br />
<br />
End Class

AnswerRe: OLEDB VS2010 and need of help! Pin
Ashfield17-Apr-10 6:15
Ashfield17-Apr-10 6:15 
Questionhow to send mail from my c# windows application [modified] Pin
Balaji_Reddy15-Apr-10 22:17
Balaji_Reddy15-Apr-10 22:17 
AnswerRe: how to send mail from my c# windows application Pin
Michel Godfroid15-Apr-10 23:44
Michel Godfroid15-Apr-10 23:44 
GeneralRe: how to send mail from my c# windows application Pin
Balaji_Reddy16-Apr-10 16:36
Balaji_Reddy16-Apr-10 16:36 
GeneralRe: how to send mail from my c# windows application Pin
Michel Godfroid16-Apr-10 21:02
Michel Godfroid16-Apr-10 21:02 
GeneralRe: how to send mail from my c# windows application Pin
Balaji_Reddy16-Apr-10 22:14
Balaji_Reddy16-Apr-10 22:14 
GeneralRe: how to send mail from my c# windows application Pin
Michel Godfroid16-Apr-10 22:20
Michel Godfroid16-Apr-10 22:20 
GeneralRe: how to send mail from my c# windows application Pin
Balaji_Reddy19-Apr-10 0:13
Balaji_Reddy19-Apr-10 0:13 
GeneralRe: how to send mail from my c# windows application Pin
Balaji_Reddy21-Apr-10 17:00
Balaji_Reddy21-Apr-10 17:00 
AnswerRe: how to send mail from my c# windows application Pin
Michel Godfroid21-Apr-10 21:28
Michel Godfroid21-Apr-10 21:28 
QuestionIIS media service Pin
Rajan UNCC 15-Apr-10 10:54
Rajan UNCC 15-Apr-10 10:54 
QuestionCustom Collection with Extension method, linq Support [modified] Pin
anand kumar m14-Apr-10 19:20
anand kumar m14-Apr-10 19:20 
AnswerRe: Custom Collection with Extension method, linq Support Pin
Not Active14-Apr-10 20:06
mentorNot Active14-Apr-10 20:06 
GeneralRe: Custom Collection with Extension method, linq Support Pin
anand kumar m14-Apr-10 20:59
anand kumar m14-Apr-10 20:59 
GeneralRe: Custom Collection with Extension method, linq Support Pin
Not Active14-Apr-10 22:21
mentorNot Active14-Apr-10 22:21 
GeneralRe: Custom Collection with Extension method, linq Support Pin
anand kumar m15-Apr-10 2:44
anand kumar m15-Apr-10 2:44 
GeneralRe: Custom Collection with Extension method, linq Support Pin
Not Active15-Apr-10 3:27
mentorNot Active15-Apr-10 3:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.