Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How do I put a chunk of code in my database?

Posted on 2011-10-13
13
Medium Priority
?
253 Views
Last Modified: 2012-05-12
I want to put the following code into a field in my sql db. For the purpose of building flash play buttons on the fly. I want each play button to be created with the object code when an audio file is added to the library. (though a asp form) The problem I’m having is errors when I try to put the code into the db.  How would I do this?
<object type="application/x-shockwave-flash" data="http://flash-mp3-player.net/medias/player_mp3_maxi.swf" width="25" height="20">
    <param name="movie" value="http://flash-mp3-player.net/medias/player_mp3_maxi.swf" />
    <param name="bgcolor" value="#ffffff" />
    <param name="FlashVars" value="mp3=test2.mp3&amp;width=25" />
</object>

Open in new window

0
Comment
Question by:bmanmike39
  • 7
  • 6
13 Comments
 
LVL 2

Expert Comment

by:Paulmc999
ID: 36963513
Can you first tell us what you have tried and what error you get?
0
 

Author Comment

by:bmanmike39
ID: 36963584
I tried to put the string of code into 2 part before the file name and after.  So I could build a string around the file name, and put all the code in the db for retrieval In a grid.  I can’t get it into a literal I get he error “Too many characters in character literal “ when I try to put it in a string variable I get the error  “; expected “  I think because of all the special charters.
0
 
LVL 2

Expert Comment

by:Paulmc999
ID: 36963654
I am just testing this but could you use datatype XML for your field type in the database?
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 

Author Comment

by:bmanmike39
ID: 36963671
I can't even begin to build the string due to the errors with the variables
0
 
LVL 2

Expert Comment

by:Paulmc999
ID: 36963705
INSERT INTO trytable
                      (first)
VALUES     (N'<object type="application/x-shockwave-flash" data="http://flash-mp3-player.net/medias/player_mp3_maxi.swf" width="25" height="20">
    <param name="movie" value="http://flash-mp3-player.net/medias/player_mp3_maxi.swf" />
    <param name="bgcolor" value="#ffffff" />
    <param name="FlashVars" value="mp3=test2.mp3&amp;width=25" />
</object> ')
0
 
LVL 2

Expert Comment

by:Paulmc999
ID: 36963802
So if the problem is building the string, you could either send the parts as seperate parameters to a SP which will insert the assembled line, or let us have the c# code that is giving you the problem so we can look at it.
0
 

Author Comment

by:bmanmike39
ID: 36963933
If  I type or past the code into a text box it will put it in the db.  I would like  the use to be able to just upload the file and I and the page create the code.  I just don’t know how to put the code in a asp.net  variable so I can use it.  I get an error because of al the special charters

This is the C# code:
protected void Page_Load(object sender, EventArgs e)
    {
        
        string x = "<object type="application/x-shockwave-flash" data="http://flash-mp3-player.net/medias/player_mp3_maxi.swf" width="25" height="20"> <param name="movie" value="http://flash-mp3-player.net/medias/player_mp3_maxi.swf" />  <param name="bgcolor" value="#ffffff" /> <param name="FlashVars" value="mp3=";
        string y = "test2.mp3";
        string z = "&amp;width=25" /> </object>";
        
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        

            Label1.Text = x + y + z;
        
    }

Open in new window

0
 

Author Comment

by:bmanmike39
ID: 36963946
OOPs wrong code here it is
string x = "<object type="application/x-shockwave-flash" data="http://flash-mp3-player.net/medias/player_mp3_maxi.swf" width="25" height="20"> <param name="movie" value="http://flash-mp3-player.net/medias/player_mp3_maxi.swf" />  <param name="bgcolor" value="#ffffff" /> <param name="FlashVars" value="mp3=";
    string y = "test2.mp3";
    string z = "&amp;width=25" /> </object>";
    
    protected void Page_Load(object sender, EventArgs e)
    {
        
        
        
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            Label1.Text = x + y + z;
        }
    }

Open in new window

0
 
LVL 2

Expert Comment

by:Paulmc999
ID: 36964023
You need to place an escape character \ before each double quote you are using within your string... try it
0
 

Author Comment

by:bmanmike39
ID: 36964151
Thanks Paulmc999 that was it
0
 

Author Comment

by:bmanmike39
ID: 36964176
I've requested that this question be closed as follows:

Accepted answer: 0 points for bmanmike39's comment http:/Q_27395316.html#36964151

for the following reason:

Thx! again
0
 
LVL 2

Accepted Solution

by:
Paulmc999 earned 2000 total points
ID: 36964177
You are welcome, but if I solved  your problem shouldn't you allocate the points to me?
0
 

Author Comment

by:bmanmike39
ID: 36964184
Whats wrong with this, i try to accept paulmc999 as the solution and this happend
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question