Click here to Skip to main content
15,886,110 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: How to convert an exe into a service Pin
gsipes30-Jun-09 3:01
gsipes30-Jun-09 3:01 
QuestionHelp Me Pin
hamed200929-Jun-09 17:39
hamed200929-Jun-09 17:39 
AnswerRe: Help Me Pin
dan!sh 29-Jun-09 19:16
professional dan!sh 29-Jun-09 19:16 
GeneralRe: Help Me Pin
hamed200929-Jun-09 21:38
hamed200929-Jun-09 21:38 
AnswerRe: Help Me Pin
Christian Graus30-Jun-09 0:16
protectorChristian Graus30-Jun-09 0:16 
GeneralRe: Help Me Pin
dan!sh 30-Jun-09 0:21
professional dan!sh 30-Jun-09 0:21 
GeneralRe: Help Me Pin
Christian Graus30-Jun-09 10:34
protectorChristian Graus30-Jun-09 10:34 
QuestionImage reference Pin
jhp53129-Jun-09 17:22
jhp53129-Jun-09 17:22 
Hi, I've looked in a few places but haven't had much luck in finding what I'm after.

So I have a picturebox on my windows form and it has an image set to it, I also have a bunch of reference files that reference to a bunch of images.

Me.PictureBox1.Image = My.Resources.imgs.image1


That piece of code works.

Now, I tried to databind the picture box to a database so the images would load on the change of a combo box but that got confusing really fast so what I did was created a database and it holds all the image references such as "My.Resources.imgs.image1" but its stored as type varchar(50).

Connecting to the database and retreiving the strings is no problem, that works all fine.

The problem is converting the string to the image reference, it doesn't work. I've tried type casting, I tried using imagelocation rather than image but I want to reference to the resources that is attached to the project.

Can anyone help me with this issue? - Thanks

Here is the full code, incase it helps
Imports System.Data.SqlClient 'before class constructor

    Dim SQLStr As String
    Private ConnString As String
    'after class constructor

'the following is within a sub
        ConnString = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\statsdata.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"

        SQLStr = "SELECT imgreference FROM tblImages WHERE (number = " + Me.ComboBox1.SelectedIndex + ")"

        Dim SQLConn As New SqlConnection() 'The SQL Connection
        Dim SQLCmd As New SqlCommand() 'The SQL Command
        Dim SQLdr As SqlDataReader        'The Local Data Store
        Dim text As String
        Dim img As Image = Nothing

        SQLConn.ConnectionString = ConnString 'Set the Connection String
        Try
            SQLConn.Open() 'Open the connection

            SQLCmd.Connection = SQLConn 'Sets the Connection to use with the SQL Command
            SQLCmd.CommandText = SQLStr 'Sets the SQL String
            SQLdr = SQLCmd.ExecuteReader() 'Executes SQL Commands Non-Querys only

            SQLdr.Read()
            text = SQLdr.GetString(0)

            SQLdr.Close() 'Close the SQLDataReader   
            SQLConn.Close() 'Close the connection

            'This is where I would change the reference of the image
            'E.g. Me.PictureBox1.Image = text - except I have to cast text from type String to type Image
            
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information, "Somethings wrong!!")
        End Try

AnswerRe: Image reference Pin
jhp53130-Jun-09 0:17
jhp53130-Jun-09 0:17 
QuestionDropdown box display issue in vb .net Pin
Member 451421829-Jun-09 17:04
Member 451421829-Jun-09 17:04 
AnswerRe: Dropdown box display issue in vb .net Pin
Henry Minute30-Jun-09 2:50
Henry Minute30-Jun-09 2:50 
QuestionDeveloping on WinXP & Office 2003, targeting WinServer2008 & Office 2007 - getting "Retrieving the COM class factory..." error Pin
Daniel Boling29-Jun-09 11:26
Daniel Boling29-Jun-09 11:26 
AnswerRe: Developing on WinXP & Office 2003, targeting WinServer2008 & Office 2007 - getting "Retrieving the COM class factory..." error Pin
Christian Graus29-Jun-09 13:21
protectorChristian Graus29-Jun-09 13:21 
AnswerRe: Developing on WinXP & Office 2003, targeting WinServer2008 & Office 2007 - getting "Retrieving the COM class factory..." error Pin
EliottA29-Jun-09 13:53
EliottA29-Jun-09 13:53 
GeneralRe: Developing on WinXP & Office 2003, targeting WinServer2008 & Office 2007 - getting "Retrieving the COM class factory..." error Pin
Daniel Boling30-Jun-09 2:41
Daniel Boling30-Jun-09 2:41 
GeneralRe: Developing on WinXP & Office 2003, targeting WinServer2008 & Office 2007 - getting "Retrieving the COM class factory..." error Pin
EliottA30-Jun-09 2:48
EliottA30-Jun-09 2:48 
QuestionMS VB 2008 express, install for all users Pin
Jesper hoegh29-Jun-09 9:12
Jesper hoegh29-Jun-09 9:12 
AnswerRe: MS VB 2008 express, install for all users Pin
Dave Kreskowiak29-Jun-09 9:45
mveDave Kreskowiak29-Jun-09 9:45 
Questionmake limit time to the vedio capture Pin
my30name29-Jun-09 5:31
my30name29-Jun-09 5:31 
AnswerRe: make limit time to the vedio capture Pin
garfield18529-Jun-09 5:34
garfield18529-Jun-09 5:34 
GeneralRe: make limit time to the vedio capture [modified] Pin
my30name29-Jun-09 22:56
my30name29-Jun-09 22:56 
QuestionString$ function Pin
garfield18529-Jun-09 5:12
garfield18529-Jun-09 5:12 
AnswerRe: String$ function Pin
Nagy Vilmos29-Jun-09 5:35
professionalNagy Vilmos29-Jun-09 5:35 
AnswerRe: String$ function Pin
Luc Pattyn29-Jun-09 5:35
sitebuilderLuc Pattyn29-Jun-09 5:35 
GeneralRe: String$ function Pin
garfield18529-Jun-09 5:46
garfield18529-Jun-09 5:46 

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.