Showing posts with label contain. Show all posts
Showing posts with label contain. Show all posts

Wednesday, March 28, 2012

How to assign SQL query to Button in asp.net 2.0

Hi

My webpage contain three dropdown box and one button. One dropdown to choose hospital_id, second dropdown to choose project_id and third dropdown to choose version_no .After choosing these three and when the button is clicked i want to run this sql query

INSERT INTO version(project_id,hospital_id,date_created,comments) SELECT project_id,hospital_id,date_created,comments FROM version whereversion_no=@.version_no andproject_id=@.project_id andhospital_id=@.hospital_id.

Just i need the code in asp.net 2.0 , VB , when the button is clicked the above query should run and the parameters (values) should take from dropdown box.

Could anyone please send the solution for the above problem.

write the query like this

Dim sQuery as String = "INSERT INTO version(project_id,hospital_id,date_created,comments) SELECT project_id,hospital_id,date_created,comments FROM version whereversion_no=" + ONE_DropDown.SelectedValue + "andproject_id=" + Second_DropDown.SelectedValue + "andhospital_id=" +THIRD_DropDown.selectedValue

Try this query

How to assign random number to one column for 500 records?

I try to set up a testing sample table which contain one integer project_ID field for table Sample around 500 records, and want the project_ID to be random number within 1 to 99, how to implement script todo it?

thanks!

Here you go !
using System
namespace x {
classe y {
public y () {}
public int getRandomID () {
Random r = new Random()
return r.Next(1,99); // this indicates the start and end limit of the random function
}
}
}

then use the returned value into your SQL query to generate the records... make sure you dont have the project_ID as primary key as this above code does not check for uniqueness of the generated number....
HTH

Wednesday, March 21, 2012

How to allow apostrophes in string parameters

I have a few reports that contain a customer name parameter. I have
just realized that when a customer name contains a single-quote
(apostrophe), reporting services thinks that it's an unclosed string
and I receive an error.
The error I get -
"An error has occurred during report processing.
Query execution failed for data set '....'.
Line 1: Incorrect syntax near 's'.
Unclosed quotation mark before the character string"."
I know that I probably need to 'escape' the single quote, but I am
unclear if I can do this on the data tab in report designer or if I
have to do this through my views/stored procs in sql server. After
determining where to make the change, I will also need to know what
the correct syntax is.
Thanks so much for your help.
CrystalOn Feb 14, 11:59=A0am, Just Another Reporter <Crystal.War...@.gmail.com>
wrote:
> I have a few reports that contain a customer name parameter. =A0I have
> just realized that when a customer name contains a single-quote
> (apostrophe), reporting services thinks that it's an unclosed string
> and I receive an error.
> The error I get -
> "An error has occurred during report processing.
> Query execution failed for data set '....'.
> Line 1: Incorrect syntax near 's'.
> Unclosed quotation mark before the character string"."
> I know that I probably need to 'escape' the single quote, but I am
> unclear if I can do this on the data tab in report designer or if I
> have to do this through my views/stored procs in sql server. =A0After
> determining where to make the change, I will also need to know what
> the correct syntax is.
> Thanks so much for your help.
> Crystal
Go to the Data tab, and click the Properties button [...] for the
Dataset. Under the Parameters tab, you will see mappings between the
parameters used in the dataset, mapped to the Report Parameters. Note
that these are expressions, so you can put your own code in here to
"escape" the single quote.
What you will want to do is do is something like:
@.Pararm =3DReplace( Parameters!Param.Value, "'", "''" )
-- Scott

Sunday, February 19, 2012

how to accquer certain number of records

hi,every body.
I want to use SQL syntax to get records from a database table. As the
table may contain large number of records,I would like to get a certain
number of records first and also can get more records later as necessary.Can
anyone help me?
CrespoHi
http://www.aspfaq.com/show.asp?id=2120
"Crespo" <wuhuanfa@.21cn.com> wrote in message
news:eWB4YGflGHA.4716@.TK2MSFTNGP04.phx.gbl...
> hi,every body.
> I want to use SQL syntax to get records from a database table. As the
> table may contain large number of records,I would like to get a certain
> number of records first and also can get more records later as
> necessary.Can
> anyone help me?
>
> Crespo
>|||Good work.Thank Uri Dimant very much!
Crespo
"Uri Dimant" <urid@.iscar.co.il> дÈëÏûÏ¢
news:eEkxHJflGHA.4716@.TK2MSFTNGP04.phx.gbl...
Hi
http://www.aspfaq.com/show.asp?id=2120
"Crespo" <wuhuanfa@.21cn.com> wrote in message
news:eWB4YGflGHA.4716@.TK2MSFTNGP04.phx.gbl...
> hi,every body.
> I want to use SQL syntax to get records from a database table. As the
> table may contain large number of records,I would like to get a certain
> number of records first and also can get more records later as
> necessary.Can
> anyone help me?
>
> Crespo
>|||"Crespo" <wuhuanfa@.21cn.com> wrote in message
news:eWB4YGflGHA.4716@.TK2MSFTNGP04.phx.gbl...
> hi,every body.
> I want to use SQL syntax to get records from a database table. As the
> table may contain large number of records,I would like to get a certain
> number of records first and also can get more records later as
necessary.Can
> anyone help me?
If using SQL 2005, look into using ROW_NUMBER also.
>
> Crespo
>|||Thank Uri Dimant. your suggestion works well. Thans again.
Crespo
"Uri Dimant" <urid@.iscar.co.il> дÈëÏûÏ¢
news:eEkxHJflGHA.4716@.TK2MSFTNGP04.phx.gbl...
Hi
http://www.aspfaq.com/show.asp?id=2120
"Crespo" <wuhuanfa@.21cn.com> wrote in message
news:eWB4YGflGHA.4716@.TK2MSFTNGP04.phx.gbl...
> hi,every body.
> I want to use SQL syntax to get records from a database table. As the
> table may contain large number of records,I would like to get a certain
> number of records first and also can get more records later as
> necessary.Can
> anyone help me?
>
> Crespo
>