473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Inserting date problem

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.se lectedvalue)

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
May 1 '06 #1
3 1369
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
"Rajani" <Ra****@discussions.microsoft.com> wrote in message
news:6D**********************************@microsof t.com...
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.se lectedvalue)

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

May 1 '06 #2
Hello,

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

what could be the problem?
"Greg Young" wrote:
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
"Rajani" <Ra****@discussions.microsoft.com> wrote in message
news:6D**********************************@microsof t.com...
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.se lectedvalue)

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


May 1 '06 #3
What about this line:
idparam.value=txtID.text

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

On Mon, 1 May 2006 02:37:01 -0700, Rajani
<Ra****@discussions.microsoft.com> wrote:
Hello,

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

what could be the problem?
"Greg Young" wrote:
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
"Rajani" <Ra****@discussions.microsoft.com> wrote in message
news:6D**********************************@microsof t.com...
> 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.se lectedvalue)
>
> 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


May 1 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: perplexed | last post by:
How do you convert a user inputted date to a unix timestamp before insterting it into your database? I have a form, with a textfield for a date that the user inputs in the format mm-dd-yyyy and...
0
by: Paolo Tardivel via DotNetMonster.com | last post by:
I have a databound datagrid containing template columns which allow editing of the values contained in the datagrid through the use of text boxes. One of the fields in the datagrid displays the...
15
by: Khurram | last post by:
I have a problem while inserting time value in the datetime Field. I want to Insert only time value in this format (08:15:39) into the SQL Date time Field. I tried to many ways, I can extract...
0
by: Niketa Mahana | last post by:
Hi, We are in the process of making product in windows forms that is localized presently for all european countries.We are supposed to support all eastern and western european date , time and...
1
by: goutamkarmakar | last post by:
dear all friends......PLEASE HELP!!!!!!!!! I AM NEW DEVELOPPER ON VB6 AND SQL SERVER 7, WHEN I AM GOING TO INSERT DATE TO SQL TABLE FROM VB THE DATE INSERTING "01/01/1900" IF IM GIVING SQL...
6
by: fniles | last post by:
I am using VB.NET 2003 and SQL Server 2000. I have a table with a datetime column type. When inserting into the table for that column, I set it to Date.Now.ToString("T") , which is something like...
13
by: imnewtoaccess | last post by:
Hi, I am getting errors while inserting records in one table from another. These are the structures of two tables : file51tm_new RecordType Text
20
by: dav3 | last post by:
Alright folks I am in need of a lil guidance/assistance here. I have a program which reads in a txt file. This txt file contains lines of the form January 3, 2007, 85.8 Now each line of the txt...
0
by: srinivasaraonagisetty | last post by:
hi, I am faceing one problem, while inserting the data in db2 using clob. actually i am writing this type code: public class DBParam { private InputStream inputstream; private static int...
2
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site for a band, I got these tables for their discography...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.