Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / May 2006

Tip: Looking for answers? Try searching our database.

Inserting date problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rajani - 01 May 2006 08:29 GMT
Hello,

I replaced the calendar control to 3 dropdownlists(day,month and year)  coz
i want to display the calendar as just like DTPicker in vb.6. But i cant able
to display like that. The form ocupies more space. But i am facing another
problem.

My table structure is staff(empid integer,joindate datetime)

i am getting the date selected as

dim doj as new datetime(yr.selectedValue,mnth.selectedvalue,dy.selectedvalue)

qry="insert into staff(empid,joindate) values(@empid,@joindate)"
dim idparam as new sqlparameter("@empid",sqlDBType.integer)
dim dtparam as new sqlparameter("@joindate",sqlDBType.datetime)
idparam.value=txtID.text
dtparam.value=doj.toShotdatestring()

conn.open()
dbcommand=new sqlcommand(qry,conn)
dbcommand.parameters.add(idparam)
dbcommand.parameters.add(dtparam)
dbcommand.executenonquery()
conn.close()

'i am getting the error "input string is not in correct format. only the
problem is with date. When using calendar, executed well. I hope some cating
problem but i couldn't resolve?

thanks for the reply
Greg Young - 01 May 2006 08:34 GMT
Don't see why you are doing the ToString(), it will only put it back to a
datetime internally .. try this.

dtparam.value=doj

Cheers,

Greg
> Hello,
>
[quoted text clipped - 31 lines]
>
> thanks for the reply
Rajani - 01 May 2006 10:37 GMT
Hello,

  I tried as u said. Still the same problem "Input string is not correct
format"

what could be the problem?

> Don't see why you are doing the ToString(), it will only put it back to a
> datetime internally .. try this.
[quoted text clipped - 39 lines]
> >
> > thanks for the reply
Chris Chilvers - 01 May 2006 17:07 GMT
What about this line:
idparam.value=txtID.text

Have you tried using:
idparam.value = Int32.Parse(txtID.text)

>Hello,
>
[quoted text clipped - 46 lines]
>> >
>> > thanks for the reply

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.