473,387 Members | 1,624 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

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
4 5107
kumsay
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
12,516 Expert Mod 8TB
The most likely problem is that you execute your reader before supplying the parameter value.
Feb 4 '13 #3
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
kumsay
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

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

Similar topics

4
by: rcb845 | last post by:
Hi everybody in the php community, I am relatively new in this field, and one of my first challenge is the following : Importing an Excel file, containings URL, into a MySQL database. It...
0
by: ramaraog80 | last post by:
Hi, I need a VB Script which exports data from CSV file to MySql Database Regards Ramarao G
7
by: mukeshpatil | last post by:
How to get data from .CSV file using php & store it into Mysql database I want to read data from two different .CSV files using php & How to store it into Mysql Database tables Please help me...
6
by: nagaraj530 | last post by:
hi friends, i want to store a video file in mysql database, if u r having any related code, please give me reply, i am waiting for that
7
by: kiranrredy | last post by:
Hi, I need to get the data from XML file , to store it in MySql database. How can i do it. Regards, KiranRredy
8
by: hemashiki | last post by:
hi i need help..how can i store image in mysql database and i want to retrive that image can anyone suggest plz
21
by: ding | last post by:
I am facing problem to writting file to MySQL database in java application. Can show me a example code? Thanks!
4
by: grouchy | last post by:
hello all, not sure if i fully explained myself on an earlier post. All i really need to do is to store an xml file into mysql database. I have no idea how to do this, including any php code i...
2
by: vinitaJ | last post by:
hi i need to convert a excel sheet to mysql database format using php code.I am not getting any help on the net on this topic.I need the code not an autogeneration tool.If any of you can solve the...
8
by: jessica87 | last post by:
hi there.... i need some guidance here with this code? Code: ( text ) 1. $myFile = "testFile.txt"; 2. $fh = fopen($myFile, 'w') or die("can't open file");
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.