• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 279
  • Last Modified:

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

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
bmanmike39
Asked:
bmanmike39
  • 7
  • 6
1 Solution
 
Paulmc999Commented:
Can you first tell us what you have tried and what error you get?
0
 
bmanmike39Author Commented:
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
 
Paulmc999Commented:
I am just testing this but could you use datatype XML for your field type in the database?
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
bmanmike39Author Commented:
I can't even begin to build the string due to the errors with the variables
0
 
Paulmc999Commented:
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
 
Paulmc999Commented:
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
 
bmanmike39Author Commented:
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
 
bmanmike39Author Commented:
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
 
Paulmc999Commented:
You need to place an escape character \ before each double quote you are using within your string... try it
0
 
bmanmike39Author Commented:
Thanks Paulmc999 that was it
0
 
bmanmike39Author Commented:
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
 
Paulmc999Commented:
You are welcome, but if I solved  your problem shouldn't you allocate the points to me?
0
 
bmanmike39Author Commented:
Whats wrong with this, i try to accept paulmc999 as the solution and this happend
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

  • 7
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now