14 Replies - 1314 Views - Last Post: 06 December 2012 - 03:24 PM Rate Topic: -----

#1 billy_welsh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 04-December 12

retrieve and insert Hyperlink to access database from VB .net

Posted 04 December 2012 - 12:58 PM

Hi, I'm using MICROSOFT.JET.OLEDB.4.0 to pull and append data to an access database.

Everything works fine except one column in the table has hyperlinks to shared folders on the network.

If I use a try catch end try it will populate the datagridview1 but pops up with and error "Record is deleted" and in the datagridview1 it shows the displayed text and the link directly proceeds it.

Something like this "linktxt#..\..\Foldername#"

This is a shorter version of the select statement I'm using. I didn't write the database so that's why the column names are not standard.


 sql = "SELECT [RFQ #],[Part Number],[Part Number Folder Link] from [Tracker]" 


For appending the data I've been trying to use a lablelink but have only been able to get the text to show in the database without the hyperlink.

Any help would be much appreciated. Thank You

Is This A Good Question/Topic? 0
  • +

Replies To: retrieve and insert Hyperlink to access database from VB .net

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5678
  • View blog
  • Posts: 12,216
  • Joined: 02-June 10

Re: retrieve and insert Hyperlink to access database from VB .net

Posted 04 December 2012 - 02:34 PM

Quote

This is a shorter version of the select statement I'm using.


Another way of saying "This is NOT the actual code I am using"

One line doesn't tell anyone very much. Please copy/paste the entire function so the experts can have the full context of what you are doing.
Was This Post Helpful? 0
  • +
  • -

#3 billy_welsh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 04-December 12

Re: retrieve and insert Hyperlink to access database from VB .net

Posted 04 December 2012 - 02:47 PM

Or it's a way of sparing people from having to look at things that are irreverent.


        Try
            con.ConnectionString = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE =NPI_Tracker.mdb" 'C:\maint.mdb"
            con.Open()

            sql = "SELECT [RFQ #],[Part Number],[Rev Level],[Originator Name],[Customer Name],[Customer Contact Information],[EAU],[Quote Due Date],[Project Risk A, B, C],[Quote Type],[Part Category],[Priority],[Platform/Package?],[Platform Number],[Preferred TSCO Mfg Site],[PPAP Level],[Special PPAP Requests Notes],[Fixture Owned By],[Tooling Owned By],[RFQ Sent to Phase 0],[Notes],[Phase 0 Initiated Date] from [NPI Tracker]"

            'sql = "SELECT [RFQ #],[Part Number],[Rev Level],[Originator Name],[Customer Name],[Customer Contact Information],[EAU],[Quote Due Date],[Project Risk A, B, C],[Quote Type],[Part Category],[Priority],[Platform/Package?],[Platform Number],[Preferred TSCO Mfg Site],[PPAP Level],[Special PPAP Requests Notes],[Fixture Owned By],[Tooling Owned By],[RFQ Sent to Phase 0],[Notes],[Phase 0 Initiated Date],[Part Number Folder Link] from [NPI Tracker]"


            da = New OleDb.OleDbDataAdapter(sql, con)
            da.Fill(ds, "NPI_Tracker")

            con.Close()

        Catch ex As Exception
            MsgBox(ex.Message)
        End Try


Was This Post Helpful? 0
  • +
  • -

#4 Musashi822  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 21
  • Joined: 28-November 12

Re: retrieve and insert Hyperlink to access database from VB .net

Posted 04 December 2012 - 03:39 PM

Quote

Something like this "linktxt#..\..\Foldername#"


If possible could you post the exact error you are receiving?
Was This Post Helpful? 0
  • +
  • -

#5 billy_welsh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 04-December 12

Re: retrieve and insert Hyperlink to access database from VB .net

Posted 04 December 2012 - 03:57 PM

What you are looking at is actually the output of the link to the datagridview the first portion up until the # is what the link text is in the database and the rest is the hyperlink. Below is a chunk of the last column "Part Number Folder Link" if I use the second sql statement. The error literally only said "Record is Deleted."


01-34285-000#..\..\DNAP\01\01-34285-000#
01-34284-001#..\..\DNAP\01\01-34284-001#
01-34284-001#..\..\DNAP\01\01-34284-001#
01-34284-000#..\..\DNAP\01\01-34284-000#
01-34284-000#..\..\DNAP\01\01-34284-000#
01-34282-000#..\..\DNAP\01\01-34282-000#
01-34276-000#..\..\DNAP\01\01-34276-000#
01-34259-000#..\..\DNAP\01\01-34259-000#
01-34259-000#..\..\DNAP\01\01-34259-000#
01-34256-000#I:\CUSTOMER FILES\DNAP\01\01-34256-000\production#
01-34255-000#I:\CUSTOMER FILES\DNAP\01\01-34255-000\production#
01-34253-000#I:\CUSTOMER FILES\DNAP\01\01-34253-000\production#
01-34239-000#..\..\DNAP\01\01-34239-000#

Attached image(s)

  • Attached Image

Was This Post Helpful? 0
  • +
  • -

#6 Musashi822  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 21
  • Joined: 28-November 12

Re: retrieve and insert Hyperlink to access database from VB .net

Posted 04 December 2012 - 04:20 PM

Quote

For appending the data I've been trying to use a lablelink but have only been able to get the text to show in the database without the hyperlink.


I am certain that you have already verified that the folder actually exists, but have you verified that the actual datatype in the database is set to a hyperlink? This would explain why you are getting it to work without a hyperlink.
Was This Post Helpful? 0
  • +
  • -

#7 billy_welsh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 04-December 12

Re: retrieve and insert Hyperlink to access database from VB .net

Posted 04 December 2012 - 04:47 PM

The folder is selected with a FolderBrowserDialog and the it is set to hyperlink. I'm sure it has more to do with my lack of knowledge on how linklables function more than anything else. I've tried LinkLabel1.links(0) and a few other variations but .text is the only thing I have found that won't pop an error.

        con.ConnectionString = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE =NPI_Tracker.mdb" 'C:\maint.mdb"
        con.Open()

        str = "insert into [NPI Tracker] ([RFQ #], [Part Number], [Rev Level], [Originator Name], [Customer Name], [Customer Contact Information], [EAU], [Quote Due Date], [Project Risk A, B, C], [Quote Type], [Part Category], [Priority], [Platform/Package?], [Platform Number], [Preferred TSCO Mfg Site], [PPAP Level], [Special PPAP Requests Notes], [Part Number Folder Link], [Fixture Owned By], [Tooling Owned By], [RFQ Sent to Phase 0], [Notes])  values('" & (combo) & "','" & (TextBox6.Text) & "','" & (TextBox7.Text) & "','" & (ComboBox1.Text) & "','" & (ComboBox2.Text) & "','" & (TextBox5.Text) & "','" & (TextBox8.Text) & "','" & (DateTimePicker1.Value.Date) & "','" & (ComboBox3.Text) & "','" & (ComboBox4.Text) & "','" & (ComboBox5.Text) & "','" & (ComboBox6.Text) & "','" & (ComboBox7.Text) & "','" & (TextBox9.Text) & "','" & (ComboBox8.Text) & "','" & (ComboBox9.Text) & "','" & (TextBox10.Text) & "','" & (LinkLabel1.Text) & "','" & (ComboBox10.Text) & "','" & (ComboBox11.Text) & "','" & (FormatDateTime(Now, DateFormat.ShortDate)) & "','" & (TextBox10.Text) & "')"


        ' str = "insert into [NPI Tracker] ([RFQ #], [Part Number], [Rev Level], [Part Number Folder Link])  values('" & (combo) & "','" & (TextBox6.Text) & "','" & (TextBox7.Text) & "','" & ("<a href=" & "http://www.ADDRESS.com" & ">Test to displat</a>") & "')"



        Cmd = New OleDb.OleDbCommand(str, con)
        icount = Cmd.ExecuteNonQuery

        con.Close()



Was This Post Helpful? 0
  • +
  • -

#8 Musashi822  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 21
  • Joined: 28-November 12

Re: retrieve and insert Hyperlink to access database from VB .net

Posted 04 December 2012 - 05:12 PM

I'm not too sure it has anything to do with your lack of knowledge of link labels, but rather combobox's in datagrids. From what I am understanding now, you are populating a datagrid with text cells and combobox cells. Everything else works except for the linklabel column when you use linklabels, but it will when you use textboxes.

If that is correct then you might not have the value member set right, as that is what would be going into the datafile. If that is not correct then I'll probably have to pass this one off to someone else as I cannot follow along with your problem. :(
Was This Post Helpful? 0
  • +
  • -

#9 billy_welsh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 04-December 12

Re: retrieve and insert Hyperlink to access database from VB .net

Posted 05 December 2012 - 08:54 AM

I'm posting a picture of the form so i can better explain what I'm trying to do. At form Load the datagrid at the bottom of the form populates from the database. The user can then click on a cell and it will fill in all available data from the row. The first part of my you can see in the second picture the link from the database fills the datagrid as a string with the file name and the link. Once the user fills in all the data into the cells and clicks add record button that's where the last code comes in and appends the data from all the textboxes and comboboxes to the database.

The second part of the problem you can see on the first picture the circled linklable I'm trying to enter into the database. If I use linklable1.text it only sends the text. I thought I would be able to send the link by using linklable1.links(0) but that wont even let me enter it in the code without throwing up an error. I hope that is a bit clearer than what I had previously.

Your time is very appreciated. If you have any ideas that's awesome if not thank you for your input.

Attached image(s)

  • Attached Image
  • Attached Image

Was This Post Helpful? 0
  • +
  • -

#10 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5678
  • View blog
  • Posts: 12,216
  • Joined: 02-June 10

Re: retrieve and insert Hyperlink to access database from VB .net

Posted 05 December 2012 - 09:02 AM

Quote

The folder is selected with a FolderBrowserDialog and the it is set to hyperlink.

Don't assume that makes it right. FolderBrowserDialog does not include an ending '\' on the path it provides. Depending on how you are building your path onto that it can cause a problem

myFolderString = "C:\folder\folder1\folder2"  ' Returned from FolderBrowserDialog


If you do something crude like just add a filename onto that you are fraked

myFullPath = myFolderString & "Filename.ext"
' becomes "C:\folder\folder1\folder2Filename.ext"


This is why you should always confirm an ending '\' and should always use System.IO.Path.Combine to build file paths.
Was This Post Helpful? 1
  • +
  • -

#11 billy_welsh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 04-December 12

Re: retrieve and insert Hyperlink to access database from VB .net

Posted 05 December 2012 - 10:42 AM

Thanks for that info when I get a chance I will force the "\" into the string.
Was This Post Helpful? 0
  • +
  • -

#12 billy_welsh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 04-December 12

Re: retrieve and insert Hyperlink to access database from VB .net

Posted 05 December 2012 - 03:03 PM

Anyone have any way of getting a hyperlink into access database with Vb?

Anyone have any way of getting a hyperlink into access database with Vb?
Was This Post Helpful? 0
  • +
  • -

#13 Musashi822  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 21
  • Joined: 28-November 12

Re: retrieve and insert Hyperlink to access database from VB .net

Posted 05 December 2012 - 03:18 PM

Quote

Thanks for that info when I get a chance I will force the "\" into the string.


You never said if you had got this to work...I think everyone looking at this thread was awaiting some sort of confirmation...
Was This Post Helpful? 0
  • +
  • -

#14 billy_welsh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 04-December 12

Re: retrieve and insert Hyperlink to access database from VB .net

Posted 05 December 2012 - 03:29 PM

Sorry about that.

I found that if I enter the data into access the way I was getting it out It would make it a Hyperlink. Since I had to append # to the string I just added the \ in as well. It worked great. That's one problem down.

This is the example of how it was outputting to the datagridview.

01-34255-000#I:\CUSTOMER FILES\DNAP\01\01-34255-000\production#

This is what I used to combined the string.
(LinkLabel1.Text & "#" & hyperlink1 & "\#")

Was This Post Helpful? 0
  • +
  • -

#15 billy_welsh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 04-December 12

Re: retrieve and insert Hyperlink to access database from VB .net

Posted 06 December 2012 - 03:24 PM

The way I got it to populate the linklable is kinda the same thing. I just reversed the process and chopped the output into sections. This was done under the DataGridView1_CellClick event. So when they click the cell the link populates along with the twenty or so other fields.

            Dim linkera As String
            Dim linkerb As String
            Dim linkvar As String

            linkvar = ds.Tables("NPI_Tracker").Rows(inc).Item(22)
            Dim linker As String() = linkvar.Split(New Char() {"#"c})

            linkera = linker(0)
            linkerb = linker(1)

            LinkLabel1.text = linkera
            hyperlink1 = linkerb




Was This Post Helpful? 0
  • +
  • -

Page 1 of 1