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

.NET (Core and Framework)

 
GeneralRe: My code keeps inserting duplicate records and I can't figure out why. Pin
Gerry Schmitz13-Mar-23 10:24
mveGerry Schmitz13-Mar-23 10:24 
AnswerRe: My code keeps inserting duplicate records and I can't figure out why. Pin
Eddy Vluggen13-Mar-23 10:37
professionalEddy Vluggen13-Mar-23 10:37 
GeneralRe: My code keeps inserting duplicate records and I can't figure out why. Pin
Ihechi Alozie13-Mar-23 10:56
Ihechi Alozie13-Mar-23 10:56 
GeneralRe: My code keeps inserting duplicate records and I can't figure out why. Pin
Eddy Vluggen13-Mar-23 11:11
professionalEddy Vluggen13-Mar-23 11:11 
QuestionIs there a need for separate SignInManager<TUser> and UserManager<TUser>? Pin
hpjchobbes26-Feb-23 9:24
hpjchobbes26-Feb-23 9:24 
AnswerRe: Is there a need for separate SignInManager<TUser> and UserManager<TUser>? Pin
Dave Kreskowiak26-Feb-23 10:45
mveDave Kreskowiak26-Feb-23 10:45 
AnswerRe: Is there a need for separate SignInManager<TUser> and UserManager<TUser>? Pin
Sardar Mudassar Ali Khan SSE10-Mar-23 7:33
professionalSardar Mudassar Ali Khan SSE10-Mar-23 7:33 
QuestionVb.net FlowLayoutPanel with MS Access: System.InvalidCastException error. Pin
sdfsdfsdfewrew3feff26-Feb-23 7:37
sdfsdfsdfewrew3feff26-Feb-23 7:37 
This is my first time that i post here and i hope that topic is correct is placed.

Please who can help me?

Error message is:
An unhandled exception of type 'System.InvalidCastException' occurred in System.Data.dll
Additional information:


This rows give error (the code was writed for MySQL and i have self changed to MS Access):
Dim len As Long = rd.GetBytes(0, 0, Nothing, 0, 0)
Dim array(CInt(len)) As Byte
rd.GetBytes(0, 0, array, 0, CInt(len))
pic = New PictureBox

Dim ms As New System.IO.MemoryStream(array)
Dim bitmap As New System.Drawing.Bitmap(ms)
pic.BackgroundImage = bitmap


Full Code:
Imports System.Data.OleDb
Public Class Form1
    Dim con As OleDbConnection
    Dim cmd As OleDbCommand
    Dim rd As OleDbDataReader

    Private WithEvents pic As New PictureBox

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        'Dim con As OleDbConnection
        'Dim cmd As OleDbCommand
        'Dim rd As OleDbDataReader

        con = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\database.accdb;")
        con.Open()

        cmd = New OleDbCommand("select * from MyTable", con)
        rd = cmd.ExecuteReader
        MsgBox("connected")

        con.Close()
        MsgBox("disconnected")
    End Sub

    Sub LoadData()
        con = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\database.accdb;")
        con.Open()
        cmd = New OleDbCommand("select * from MyTable", con)
        rd = cmd.ExecuteReader
        While rd.Read
            Dim len As Long = rd.GetBytes(0, 0, Nothing, 0, 0)
            Dim array(CInt(len)) As Byte
            rd.GetBytes(0, 0, array, 0, CInt(len))
            pic = New PictureBox

            Dim ms As New System.IO.MemoryStream(array)
            Dim bitmap As New System.Drawing.Bitmap(ms)
            pic.BackgroundImage = bitmap

            FlowLayoutPanel1.Controls.Add(pic)

        End While
        rd.Close()
        con.Close()
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        LoadData()
    End Sub
End Class

AnswerRe: Vb.net FlowLayoutPanel with MS Access: System.InvalidCastException error. Pin
Richard Deeming26-Feb-23 23:31
mveRichard Deeming26-Feb-23 23:31 
GeneralRe: Vb.net FlowLayoutPanel with MS Access: System.InvalidCastException error. Pin
sdfsdfsdfewrew3feff27-Feb-23 7:55
sdfsdfsdfewrew3feff27-Feb-23 7:55 
GeneralRe: Vb.net FlowLayoutPanel with MS Access: System.InvalidCastException error. Pin
Richard Deeming27-Feb-23 22:17
mveRichard Deeming27-Feb-23 22:17 
AnswerRe: Vb.net FlowLayoutPanel with MS Access: System.InvalidCastException error. Pin
Dave Kreskowiak27-Feb-23 4:14
mveDave Kreskowiak27-Feb-23 4:14 
GeneralRe: Vb.net FlowLayoutPanel with MS Access: System.InvalidCastException error. Pin
sdfsdfsdfewrew3feff27-Feb-23 9:36
sdfsdfsdfewrew3feff27-Feb-23 9:36 
AnswerRe: Vb.net FlowLayoutPanel with MS Access: System.InvalidCastException error. Pin
jschell13-Mar-23 7:30
jschell13-Mar-23 7:30 
QuestionXML view to display in grid view Pin
Member 1592502915-Feb-23 6:30
Member 1592502915-Feb-23 6:30 
QuestionSystem.Design - Not enough memory resources Pin
JoshWilliams5-Jan-23 11:37
JoshWilliams5-Jan-23 11:37 
AnswerRe: System.Design - Not enough memory resources Pin
Dave Kreskowiak5-Jan-23 15:25
mveDave Kreskowiak5-Jan-23 15:25 
GeneralRe: System.Design - Not enough memory resources Pin
trønderen5-Jan-23 16:09
trønderen5-Jan-23 16:09 
GeneralRe: System.Design - Not enough memory resources Pin
Dave Kreskowiak5-Jan-23 16:35
mveDave Kreskowiak5-Jan-23 16:35 
GeneralRe: System.Design - Not enough memory resources Pin
trønderen5-Jan-23 18:54
trønderen5-Jan-23 18:54 
GeneralRe: System.Design - Not enough memory resources Pin
Eddy Vluggen6-Jan-23 0:55
professionalEddy Vluggen6-Jan-23 0:55 
GeneralRe: System.Design - Not enough memory resources Pin
Pete O'Hanlon6-Jan-23 3:11
subeditorPete O'Hanlon6-Jan-23 3:11 
GeneralRe: System.Design - Not enough memory resources Pin
Dave Kreskowiak6-Jan-23 12:44
mveDave Kreskowiak6-Jan-23 12:44 
GeneralRe: System.Design - Not enough memory resources Pin
jschell10-Jan-23 7:46
jschell10-Jan-23 7:46 
GeneralRe: System.Design - Not enough memory resources Pin
Dave Kreskowiak10-Jan-23 7:47
mveDave Kreskowiak10-Jan-23 7:47 

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.