Showing posts with label textbox. Show all posts
Showing posts with label textbox. Show all posts

Tuesday, March 6, 2012

Add New Record into table

Hi , All
I default value in textbox for show now date and I used to method

txtDate.Text = Now.ToShortDateString

It's have problem when I want to add new record in table

I get error message "The statement has been terminated. String or binary data would be truncated. "

and I set type in database is char length 10 ,I can't set type is datetime because in SQL Server fix type datetime

It's have length 8 but 8 length it's not enough for default value
Please help me
Thanks
Nisarat

First use DateTime.Now.ToShortDateString
Secondly use 'yyyy-MM-dd' eg. '2005-06-01'(notice the single quote ' ) format while inserting data.
|||

Hi, dinuj

I set type of field date is datetime and set default value "dd/mm/yyyy" but I get error message "Error validating the default for column "datekey""
Thanks
Nisarat

|||Do mean to say that you are trying to set a default date for the coloumn datekey
|||

Hi,Dinuj

yes ,I trying set type of field DateKey is DateTime type but ,in SQLServer it's 8 char only and I will trying to defaulf value in this field but It's can not
Thanks
Nisarat

|||

Nisarat wrote:

Hi,Dinuj

yes ,I trying set type of field DateKey isDateTime type but ,in SQLServer it's 8 char only and I willtrying to defaulf value in this field but It's can not
Thanks
Nisarat


Is your DateKey column is of DateTime type? DateTime is 8 bytes widenot 8 chars. Are you using Enterprise Manager ? If yes then clickon Default value and set the default date to whatever you want in thisformat 'yyyyMMdd' . For example for today '20050606'

Add n numbers of days to a date

Hi,

I have a textbox with date selected from calendar... Now i put in another textbox to enters number of day(30 or 120 or other), this number may vary...

so my qns is how to add the n numbers of days entered to the date selected? i stored date as smalldatetime

Help is appreciated

There is a function DATEADD you can use:

DATEADD(dd, yourFirstDate, 30)-- add 30 days to your first date.

you can use this in your insert or update statement. Let me know if you need more help.

|||

U r having the function Dateadd. U use the function

DATEADD(datepart,number,date)

DatepartAbbreviationsYearyy, yyyyquarterqq, qMonthmm, mdayofyeardy, yDaydd, dWeekwk, wwHourhhminutemi, nsecondss, smillisecondms

Thanks

Baba

Please remember to click "Mark as Answer" on this post if it helped you.

|||

Hi all,

Thank for replying.. Oh y under this section... Anyway i dun quite understand how to implement it in my codes...

Cos my Textbox for user to enter number of days to due date may vary... Like as i say in abv example

Step1: User select the firstdate from a calendar and display in TextBox1.Text (12/11/2007)

Step2: User enter the number of days to due date in TextBox2.Text (example, 30) <-- can be any number...no specific

Step3: On click a button it display the 12/12/2007 in a label maybe...

Step4: this label date is save to sql for future use...

So i need know how to implement it... as most example i googled has a specific days declare... As for step4 is easy so i only need to know step2 and 3

Any details example of how to do it?

Ur help is appreciated

Edit: I have try this codes... it works but how can i not specific the number of days... i wan the user to specific any number of days they want in TextBox2

Dim nowAsNew DateTime

now = tb_dop.Text

Dim lAsNew DateTime

l = now.AddDays(30)

TextBox1.Text = l

|||

OK

Thanks for the helps... I have figure it out as followed

Dim nowAsNew DateTime

now = tb_dop.Text

Dim iAsInteger

i = TextBox1.Text

Dim lAsNew DateTime

l = now.AddDays(i)

TextBox1.Text = l

Thursday, February 16, 2012

Add AM or PM to date in text box

How do i add eith AM or PM at the end of the date in the expression of a
textbox
this is what i currently have
format(Globals!ExecutionTime, "dd/MM/yy hh:mm")
but i want it to output 02/08/06 5:02 PM
thanks in advanceTango wrote:
> How do i add eith AM or PM at the end of the date in the expression of a
> textbox
> this is what i currently have
> format(Globals!ExecutionTime, "dd/MM/yy hh:mm")
> but i want it to output 02/08/06 5:02 PM
> thanks in advance
Remove the Format and just give Globals!ExecutionTime.it will do what
you want
Regards
Raj Deep.A|||Thanks
but the date is round the wrong way, its outputting 02/08/06 5:02 PM (ie
MM/dd/yy)
"RajDeep" wrote:
> Tango wrote:
> > How do i add eith AM or PM at the end of the date in the expression of a
> > textbox
> >
> > this is what i currently have
> >
> > format(Globals!ExecutionTime, "dd/MM/yy hh:mm")
> >
> > but i want it to output 02/08/06 5:02 PM
> >
> > thanks in advance
> Remove the Format and just give Globals!ExecutionTime.it will do what
> you want
> Regards
> Raj Deep.A
>|||Oh Sorry,
You can achieve that by format(Globals!ExecutionTime, "dd/MM/yy
hh:mm:ss tt")
regards
Raj Deep.A
Tango wrote:
> Thanks
> but the date is round the wrong way, its outputting 02/08/06 5:02 PM (ie
> MM/dd/yy)
> "RajDeep" wrote:
> >
> > Tango wrote:
> > > How do i add eith AM or PM at the end of the date in the expression of a
> > > textbox
> > >
> > > this is what i currently have
> > >
> > > format(Globals!ExecutionTime, "dd/MM/yy hh:mm")
> > >
> > > but i want it to output 02/08/06 5:02 PM
> > >
> > > thanks in advance
> >
> > Remove the Format and just give Globals!ExecutionTime.it will do what
> > you want
> >
> > Regards
> > Raj Deep.A
> >
> >|||Thanks heaps Raj.
"RajDeep" wrote:
> Oh Sorry,
> You can achieve that by format(Globals!ExecutionTime, "dd/MM/yy
> hh:mm:ss tt")
> regards
> Raj Deep.A
> Tango wrote:
> > Thanks
> >
> > but the date is round the wrong way, its outputting 02/08/06 5:02 PM (ie
> > MM/dd/yy)
> >
> > "RajDeep" wrote:
> >
> > >
> > > Tango wrote:
> > > > How do i add eith AM or PM at the end of the date in the expression of a
> > > > textbox
> > > >
> > > > this is what i currently have
> > > >
> > > > format(Globals!ExecutionTime, "dd/MM/yy hh:mm")
> > > >
> > > > but i want it to output 02/08/06 5:02 PM
> > > >
> > > > thanks in advance
> > >
> > > Remove the Format and just give Globals!ExecutionTime.it will do what
> > > you want
> > >
> > > Regards
> > > Raj Deep.A
> > >
> > >
>

Monday, February 13, 2012

Add a checkbox report item

Hi there,

I am using SQL Server 2005 Reporting Services. Right now, I have a textbox with 0 or 1 values in my report and I want to show a checkbox: checked for value 1 and uncheck for 0. Is there anyway to add a checkbox in the report?

Thanks in advance.

semaj

A bit of a hack, but I think the only way to do this is to create 2 images of a checkbox (checked and unchecked), place that on your report and set the source to be an expression based on your field value.

=Iif(Fileds!check.Value = 0, "unchecked.gif", "checked.gif")