Showing posts with label page. Show all posts
Showing posts with label page. Show all posts

Wednesday, March 7, 2012

inserting video from sql into embedded media

Hi i have a video file path stored in my sql database and i have an embedded media player in my web page, how can i load up a different video file into the embedded media player based on movie id or movie name, this is the code i have written so far but im unsure if im in the right direction, thanks

sorry this is the code

<

formid="form1"runat="server"><palign="center"><OBJECTID="Player"

CLASSID

="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"

VIEWASTEXT

><PARAMname="autoStart"value="True"><PARAMname="URL"value="<%# Eval("MovieFile") %>"><PARAMname="rate"value="1"><PARAMname="balance"value="0"><PARAMname="enabled"value="true"><PARAMname="enabledContextMenu"value="true"><PARAMname="fullScreen"value="false"><PARAMname="playCount"value="1"><PARAMname="volume"value="100">

</

OBJECT></p>

|||

Hi Peter,

Naturally, you can pass the value from database to the url attribute of the object. And about the usage of ActiveX controls from Internet Explorer, you may refer the following kb article:

http://support.microsoft.com/kb/555687

If this does not help you,pls feel free to mark the post as Not Answered and reply.

Thanks.

Friday, February 24, 2012

inserting to multiple fields using a button

I have multiple textboxes in a page. How do i make them insert their values to multiple fields on multiple tables using a button.

You can just execute some SqlCommands to insert data to different tables in the Click event of a button, for example:

protected void Button2_Click(object sender, EventArgs e)
{
using (SqlConnection conn = new SqlConnection(@."Data Source=labsh96223\iori2000;Integrated Security=SSPI;Database=tempdb"))
{
conn.Open();
string insertSql = @."Insert into myTbl_1 select @.id, @.name";
SqlCommand myCommand = new SqlCommand(insertSql, conn);
myCommand.Parameters.Add("@.id", SqlDbType.Int);
myCommand.Parameters.Add("@.name", SqlDbType.VarChar, 100);
myCommand.Parameters["@.id"].Value = Int32.Parse(TextBox1.Text);
myCommand.Parameters["@.name"].Value = TextBox2.Text;
int i = myCommand.ExecuteNonQuery();
myCommand.CommandText = @."Insert into myTbl_2 select @.id, @.Description";
myCommand.Parameters.Clear();
myCommand.Parameters.Add("@.id", SqlDbType.Int);
myCommand.Parameters.Add("@.Description", SqlDbType.VarChar, 1000);
myCommand.Parameters["@.id"].Value = Int32.Parse(TextBox3.Text);
myCommand.Parameters["@.name"].Value = TextBox4.Text;
i= myCommand.ExecuteNonQuery();
//execute other commands
}
}

Inserting special characters

Hi
I have a web page where users insert some comments into a text area. users
are able to insert any character into this area. When they submit the
character ' and " causes problems. How can i allow these characters to be
inserted into the database( sql server 2000)?
I am using Java server page to process and insert the comments to the
database.
thanksHi,
Not quite sure what you are trying exactly. Just try using NVARCHAR data
type and see if it helps.
Thanks
Hari
SQL Server MVP
"panda" <panda@.discussions.microsoft.com> wrote in message
news:CF0A3B21-D97F-44C6-800B-88B3B54E501C@.microsoft.com...
> Hi
> I have a web page where users insert some comments into a text area. users
> are able to insert any character into this area. When they submit the
> character ' and " causes problems. How can i allow these characters to be
> inserted into the database( sql server 2000)?
> I am using Java server page to process and insert the comments to the
> database.
> thanks|||This would be less of a problem if you were using stored procedures. Since
you are probably sending query strings from the web page to the SQL Server,
you may be very vulnerable to SQL Injection attacks. (Write to me off line
and I will give you more information about your vulnerability.)
For the single quote, if you must store them, have the application double
(two single quotes) them before sending to SQL Server. The double quote
shouldn't be a problem -please confirm how you are experiencing the problem.
--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"panda" <panda@.discussions.microsoft.com> wrote in message
news:CF0A3B21-D97F-44C6-800B-88B3B54E501C@.microsoft.com...
> Hi
> I have a web page where users insert some comments into a text area. users
> are able to insert any character into this area. When they submit the
> character ' and " causes problems. How can i allow these characters to be
> inserted into the database( sql server 2000)?
> I am using Java server page to process and insert the comments to the
> database.
> thanks|||HI,
I am trying to insert a ' charcerter. However the SQL syntax for inserting
nvarchar or strings use the ' character to determine the begining and the
end.
How do i go about inserting a ' character into the database?
"Hari Prasad" wrote:
> Hi,
> Not quite sure what you are trying exactly. Just try using NVARCHAR data
> type and see if it helps.
> Thanks
> Hari
> SQL Server MVP
> "panda" <panda@.discussions.microsoft.com> wrote in message
> news:CF0A3B21-D97F-44C6-800B-88B3B54E501C@.microsoft.com...
> > Hi
> >
> > I have a web page where users insert some comments into a text area. users
> > are able to insert any character into this area. When they submit the
> > character ' and " causes problems. How can i allow these characters to be
> > inserted into the database( sql server 2000)?
> >
> > I am using Java server page to process and insert the comments to the
> > database.
> >
> > thanks
>
>|||This is a multi-part message in MIME format.
--=_NextPart_000_05F8_01C6C63E.8066A380
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: quoted-printable
Use two of them, for example:
CREATE TABLE #MyTable
( RowID int IDENTITY
, MyStringValue varchar(100)
)
INSERT INTO #MyTable VALUES ('"This isn''t so obvious, is it?", said =Bill O''Shea to Terrance O''Donald.')
SELECT MyStringValue FROM #MyTable
DROP TABLE #MyTable
Hope that this helps...
-- Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience. Most experience comes from bad judgment. - Anonymous
"panda" <panda@.discussions.microsoft.com> wrote in message =news:26E49E21-4F45-4F5E-ABD2-BD5E5D8771C4@.microsoft.com...
> HI,
> > I am trying to insert a ' charcerter. However the SQL syntax for =inserting > nvarchar or strings use the ' character to determine the begining and =the > end. > > How do i go about inserting a ' character into the database?
> > "Hari Prasad" wrote:
> >> Hi,
>> >> Not quite sure what you are trying exactly. Just try using NVARCHAR =data >> type and see if it helps.
>> >> Thanks
>> Hari
>> SQL Server MVP
>> >> "panda" <panda@.discussions.microsoft.com> wrote in message >> news:CF0A3B21-D97F-44C6-800B-88B3B54E501C@.microsoft.com...
>> > Hi
>> >
>> > I have a web page where users insert some comments into a text =area. users
>> > are able to insert any character into this area. When they submit =the
>> > character ' and " causes problems. How can i allow these characters =to be
>> > inserted into the database( sql server 2000)?
>> >
>> > I am using Java server page to process and insert the comments to =the
>> > database.
>> >
>> > thanks >> >> --=_NextPart_000_05F8_01C6C63E.8066A380
Content-Type: text/html;
charset="Utf-8"
Content-Transfer-Encoding: quoted-printable
=EF=BB=BF<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
&

Use two of them, for =example:
CREATE TABLE =#MyTable ( =RowID int IDENTITY , MyStringValue varchar(100) )
INSERT INTO #MyTable VALUES ('"This isn''t so obvious, is it?", =said Bill O''Shea to Terrance O''Donald.')
SELECT MyStringValue FROM #MyTable
DROP TABLE #MyTable
Hope that this helps...
-- Arnie Rowland, =Ph.D.Westwood Consulting, Inc
Most good judgment comes from =experience. Most experience comes from bad judgment. - Anonymous
"panda" wrote in message news:26E49E21-4F45-4F5E-ABD2-BD5E5D8771C4@.microsoft.com...> =HI,> > I am trying to insert a ' charcerter. However the SQL syntax =for inserting > nvarchar or strings use the ' character to determine =the begining and the > end. > > How do i go about =inserting a ' character into the database?> > "Hari Prasad" =wrote:> > Hi,> > Not quite sure what you are =trying exactly. Just try using NVARCHAR data > type and see if it helps.> > Thanks> Hari> SQL =Server MVP> > "panda" wrote in message > news:CF0A3B21-D97F-44C6-800B-88B3B54E501C@.microsoft.com...> > Hi> =>> > I have a web page where users insert some comments into a text area. users> > are able to insert any character into this area. =When they submit the> > character ' and " causes problems. How =can i allow these characters to be> > inserted into the =database( sql server 2000)?> >> > I am using Java server =page to process and insert the comments to the> > =database.> >> > thanks > > >

--=_NextPart_000_05F8_01C6C63E.8066A380--

Inserting special characters

Hi
I have a web page where users insert some comments into a text area. users
are able to insert any character into this area. When they submit the
character ' and " causes problems. How can i allow these characters to be
inserted into the database( sql server 2000)?
I am using Java server page to process and insert the comments to the
database.
thanksHi,
Not quite sure what you are trying exactly. Just try using NVARCHAR data
type and see if it helps.
Thanks
Hari
SQL Server MVP
"panda" <panda@.discussions.microsoft.com> wrote in message
news:CF0A3B21-D97F-44C6-800B-88B3B54E501C@.microsoft.com...
> Hi
> I have a web page where users insert some comments into a text area. users
> are able to insert any character into this area. When they submit the
> character ' and " causes problems. How can i allow these characters to be
> inserted into the database( sql server 2000)?
> I am using Java server page to process and insert the comments to the
> database.
> thanks|||This would be less of a problem if you were using stored procedures. Since
you are probably sending query strings from the web page to the SQL Server,
you may be very vulnerable to SQL Injection attacks. (Write to me off line
and I will give you more information about your vulnerability.)
For the single quote, if you must store them, have the application double
(two single quotes) them before sending to SQL Server. The double quote
shouldn't be a problem -please confirm how you are experiencing the problem.
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"panda" <panda@.discussions.microsoft.com> wrote in message
news:CF0A3B21-D97F-44C6-800B-88B3B54E501C@.microsoft.com...
> Hi
> I have a web page where users insert some comments into a text area. users
> are able to insert any character into this area. When they submit the
> character ' and " causes problems. How can i allow these characters to be
> inserted into the database( sql server 2000)?
> I am using Java server page to process and insert the comments to the
> database.
> thanks|||HI,
I am trying to insert a ' charcerter. However the SQL syntax for inserting
nvarchar or strings use the ' character to determine the begining and the
end.
How do i go about inserting a ' character into the database?
"Hari Prasad" wrote:

> Hi,
> Not quite sure what you are trying exactly. Just try using NVARCHAR data
> type and see if it helps.
> Thanks
> Hari
> SQL Server MVP
> "panda" <panda@.discussions.microsoft.com> wrote in message
> news:CF0A3B21-D97F-44C6-800B-88B3B54E501C@.microsoft.com...
>
>|||Use two of them, for example:
CREATE TABLE #MyTable
( RowID int IDENTITY
, MyStringValue varchar(100)
)
INSERT INTO #MyTable VALUES ('"This isn''t so obvious, is it?", said Bill O'
'Shea to Terrance O''Donald.')
SELECT MyStringValue
FROM #MyTable
DROP TABLE #MyTable
Hope that this helps...
--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc
Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous
"panda" <panda@.discussions.microsoft.com> wrote in message news:26E49E21-4F45-4F5E-ABD2-BD5E
5D8771C4@.microsoft.com...[vbcol=seagreen]
> HI,
>
> I am trying to insert a ' charcerter. However the SQL syntax for inserting
> nvarchar or strings use the ' character to determine the begining and the
> end.
>
> How do i go about inserting a ' character into the database?
>
> "Hari Prasad" wrote:
>

Inserting records using the details view or programmatically

I'm a new user to vwd.

If I use a details view control on my page, I have noticed that the "New" link is not visible unless there is at least one record in the table. Is there any way of making it visible where there aren't any records?

My web pages are currently hosted at vwdhosting. I have uploaded my database with the record structure onto the web site and I am using a remote connection string to access it. I have had users updating data in another table on the remote database. If I add records to my new table locally and upload the database to the remote site, all the data that my users have been adding will be lost.

So, if I can't add my first record using a control on my web page when there are no records in the table, should I be doing it programmatically? If so, how?

Thanks,

Julie

Use the empty template. Add a button, that has a commandname of "New".

I usually use something like:

No records found, <asp:button ...>Add a new record</asp:button>

as the empty template.

|||Fabulous, thank you.

Sunday, February 19, 2012

Inserting Records

Hi,

I'm using VWD 2005 Express with SQL Server 2005 Express. I've created a page "create.aspx" which will be used to insert records into a table within the database.

I've used the DetailsView control together with a SqlDataSource control on the create.aspx page.

When I run the create.aspx page it retrieves the first record in the table of the database becuase the SqlDataSource is obviously performing a"Select * from Table" command.

I don't want this to occur. I want an empty page with no records. I know I can set a WHERE clause to a value that will never return any results but I don't beleieve this is an elegant way of doing things becuase I am 'hitting the database' for no reason other than to get the table structure poplutaed into the DetailsView control.

Questions:

1. Am I using the right controls? (in particular the SqlDataSource control)

2. Is there a better way of doing this?

Your advice is most appreciated. Thank you

Try a formview with the defaultmode set to insert.

|||Motley, Thank you - that works just fine|||

Hi, I'm stuck again. Beginners bad luck.

Let's say I have a database with one table e.g. AccountsTable and this table has several fields such as:AccountID, AccountName, AccountDate, AccountActive etc.

I'm using the FormView with the DeafultMode set to Insert with:

<asp:TextBoxID="AccountDateEstablishedTextBox"runat="server"Text='<%# Bind("AccountDateEstablished") %>'></asp:TextBox>

How do I access and assign the database field?

I would like to programmatically take control. Say for example in the Sub Page_Load (not sure if this is where it should go) have something like

AccountDateEstablished = now

But I get the message saying AccountDateEstablished is not declared. Obviously, it's not referring to the same thing as what I have in mind i.e. I think it's looking for a variable in the codebehind file; when what I want is to have some logic that assigns this field in the database the value of 'now' i.e. this moment in time e.g. 21 Feb 2006.

I have the same issue with a CheckBox used for the AccountActive which is a Bit (I assume this means Boolean). All I want is for it to default to 'True' when the page loads

Another issue also closely releated. If I place a Calendar control otside the FormView then I can access the value Calendar1.SelectedDate as a vlaue in the SqlDataSource1 propoerty InsertQuery, choose AccountDateEstablished and choose from 'Control' form the Parameter Source drop down. However, if I place the Calendar control within the Formview then I cannot access this control or value.

Also, if you had a regular aspx page with a button then I could place some logic in the Click event to check for certain conditions etc. How do you do this with the prewritten FormView "Insert" Linkbutton (or Button)?

Thanks

|||

You don't assign the value to the database, the values don't get written to the database until you actually click the insert button.

It looks like you are binding the AccountDateEstablished to the AccountDateEstablishedTextbox, so if you want it to get written when you click insert, you can of course, just do:

AccountDateEstablishedTextbox.text=now

Of course, that let's the user edit the text, if that is not what you wanted, then don't bind it to a textbox, and on page load, you can do something like:

SqlDataSource1.InsertParameters("@.AccountDateEstablished").defaultvalue=now

And make the AccountDateEstablished a Parameter instead of a ControlParameter. You can also set the value during the SqlDataSource1_Inserting event.

Same for the checkbox. If you want the default to be checked, then set it as checked in page load, or if you always want it to default to checked, then just set the property of the checkbox to checked=true.

Try placing the SqlDatasouce within the formview and see if that fixes your calendar issue -- but I'm not an expert on this, I've avoided the FormView controls, etc. so far.

I would go to the code behind page, select FormView in the upper left dropdown, then see all the events I could catch in the upper right dropdown, I'm sure there is one in there that would be helpful.

|||

It looks like you are binding the AccountDateEstablished to the AccountDateEstablishedTextbox,(Yes, the system did that for me) so if you want it to get written when you click insert, you can of course, just do:

AccountDateEstablishedTextbox.text=now

Of course, that let's the user edit the text(That's fine - the easy way for now [I don't know the difference between Parameter and Control Parameter]).

Prior to submitting the post, and yet again upon your response, I have tried this in the code behind under several different combinations (upper left and right drop downs) but I keep getting the squiggly line NAME'AccountDateEstablishedTextbox' is not declared

I even triedFormView1.AccountDateEstablishedTextbox.textwith no joy i.e. I get the same message of not declared. Do I have to try each and every combination? I feel like I am missing something big here

Normally you can access a control properties in code as you mentioned withAccountDateEstablishedTextbox.text=now, but this FormView seems to be behaving differently by 'hiding the textbox control' that it created

The page has a master page, does that have any side effect?Thanks

|||

I would recommend asking that question in the data presentation controls forum. Hopefully they have a better solution for you than the only one I know of which is to do something silly like this:

CType(FormView1.FindControl("AccountDateEstablishedTextbox"),textbox).text=""

I finally realized that the FormView was wasting more of my time with sillyness like that than to just load and insert my own data so I chucked it, and did that instead.

|||

Hi Motley,

Thanks for better suggesion for inserting records. I was also face problems when i inserting hidden values. Finally I did using "e.Command.Parameters["@.EmployeeID"].Value = Profile.EmpID;" using SqlDataSource1_Inserting event.

FormView/DataList controls seems to simple when I see webcast events but it acutally time consuming at real time development. esp Inserting / Display records.

Regards,

Gopinath,

inserting NULL into Datetime and int

Hello,

I have an asp.net page with different textboxes that put text into an sql database.
When I try to leave the textboxes blank that correspond with datatypes of int and datetime
in sql server it gives an error : I need to fill in these textboxes.

How can I solve this problem so I can leave the boxes blanc? What is the best sollution for this? I know I can set the types to String but then the user could fill in what he wants :)
Could you give me some advice on this please? All ideas are welcome.
Thanks !if you strictly want to enforce the user to enter the proper data and not mess up the system, use customvalidators for the textboxes.

for date, you can prbly have three textboxes for month, yr and day and validate it to numeric and when you add the values to db, concatenate them with a "/" in between.

or if the user leaves it blank, check if the txtDate.text = "" then use system.dbnull to enter null into the db.

HTH.|||Hey thanks ndinakar :)

Ok I've looked in the .net classes for this dbnull. There's no good example of how to do that.
Do I use this dbnull on the page script or in the database (for example in a stored procedure?)
Could you give an example please?(I'm very noob)

Thanks again for replying !