By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,239 Members | 1,493 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,239 IT Pros & Developers. It's quick & easy.

how to store file path in mysql database retrieve it using vb.net

P: 25
hello, I have form with a listbox and a windows media player. The lisbox is populated with filename from the database. If the user select one item from listbox a video clip should play on the WMP. In the mysql database, I have a table VideoClips with fields vName(varchar), vLocation(varchar). In vLocation I saved the file path of the picture (D:\VBProject\videos\video.flv).
Expand|Select|Wrap|Line Numbers
  1. Call Connect()
  2.         With Me
  3.             STRSQL = "select vLocation from movie where vName = @vName"
  4.             Try
  5.                 myCmd.Connection = myConn
  6.                 myCmd.CommandText = STRSQL
  7.                 myReader = myCmd.ExecuteReader
  8.                 myCmd.Parameters.AddWithValue("@vName", lstName.SelectedItem.ToString())
  9.  
  10.                 If myReader.Read Then
  11.                     Dim path = myReader.GetString(0)
  12.                     wmp.URL = path
  13.                 End If
  14.             Catch ex As Exception
  15.                 MsgBox("no file")
  16.             End Try
  17.  
  18.         End With
  19.  
there's no error, the problem is that when I select an item in the list it displays the catch exception message "no file" even if I already have the full path of the video stored in the database (example: D:\VBProject\videos\video.flv). Can anybody help me work it properly? this is quite urgent, I need to finish this today. Please help me, God bless
Feb 3 '13 #1
Share this Question
Share on Google+
4 Replies


P: 25
I browse and found a forum in the internet that \ should not be used because within MySQL string values the backslash is interpreted as an escape character and suggested to alter the path values to contain the "\" sequence to actually store a backslash. So I stored the file path as D:\\VBProject\\videos\\sample.flv but still failed :(
Feb 3 '13 #2

Rabbit
Expert Mod 10K+
P: 12,383
The most likely problem is that you execute your reader before supplying the parameter value.
Feb 4 '13 #3

P: 31
Hi ! i think it will help you

[code]STRSQL = "Select pLocation From Pix where pixName = @pixName"
myCmd.Parameters.AddWithValue("@pixName",lstPix.Se lectedItem.ToString())[/cod]e
Feb 4 '13 #4

P: 25
I already got it working, here's my working code:
Expand|Select|Wrap|Line Numbers
  1. Call Connect()
  2.         With Me
  3.             STRSQL = "select vLocation from movie where vName = '" & lstName.SelectedItem & "'"
  4.             Try
  5.                 myCmd.Connection = myConn
  6.                 myCmd.CommandText = STRSQL
  7.                 myReader = myCmd.ExecuteReader
  8.  
  9.                 If myReader.Read Then
  10.                     Dim path = myReader.GetString(0)
  11.                     wmp.URL = path
  12.  
  13.                 End If
  14.             Catch ex As Exception
  15.                 MsgBox("no file")
  16.             End Try
  17.           myConn.Close()
  18.         End With
  19.  
I stored the file path with single \ (D:\VBProject\videos\video.flv). Thanks anyway :)
Feb 4 '13 #5

Post your reply

Sign in to post your reply or Sign up for a free account.