473,782 Members | 2,448 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inserting date problem

Hello,

I replaced the calendar control to 3 dropdownlists(d ay,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,joindat e datetime)

i am getting the date selected as

dim doj as new datetime(yr.sel ectedValue,mnth .selectedvalue, dy.selectedvalu e)

qry="insert into staff(empid,joi ndate) values(@empid,@ joindate)"
dim idparam as new sqlparameter("@ empid",sqlDBTyp e.integer)
dim dtparam as new sqlparameter("@ joindate",sqlDB Type.datetime)
idparam.value=t xtID.text
dtparam.value=d oj.toShotdatest ring()

conn.open()
dbcommand=new sqlcommand(qry, conn)
dbcommand.param eters.add(idpar am)
dbcommand.param eters.add(dtpar am)
dbcommand.execu tenonquery()
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 1393
Don't see why you are doing the ToString(), it will only put it back to a
datetime internally .. try this.

dtparam.value=d oj

Cheers,

Greg
"Rajani" <Ra****@discuss ions.microsoft. com> wrote in message
news:6D******** *************** ***********@mic rosoft.com...
Hello,

I replaced the calendar control to 3 dropdownlists(d ay,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,joindat e datetime)

i am getting the date selected as

dim doj as new
datetime(yr.sel ectedValue,mnth .selectedvalue, dy.selectedvalu e)

qry="insert into staff(empid,joi ndate) values(@empid,@ joindate)"
dim idparam as new sqlparameter("@ empid",sqlDBTyp e.integer)
dim dtparam as new sqlparameter("@ joindate",sqlDB Type.datetime)
idparam.value=t xtID.text
dtparam.value=d oj.toShotdatest ring()

conn.open()
dbcommand=new sqlcommand(qry, conn)
dbcommand.param eters.add(idpar am)
dbcommand.param eters.add(dtpar am)
dbcommand.execu tenonquery()
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=d oj

Cheers,

Greg
"Rajani" <Ra****@discuss ions.microsoft. com> wrote in message
news:6D******** *************** ***********@mic rosoft.com...
Hello,

I replaced the calendar control to 3 dropdownlists(d ay,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,joindat e datetime)

i am getting the date selected as

dim doj as new
datetime(yr.sel ectedValue,mnth .selectedvalue, dy.selectedvalu e)

qry="insert into staff(empid,joi ndate) values(@empid,@ joindate)"
dim idparam as new sqlparameter("@ empid",sqlDBTyp e.integer)
dim dtparam as new sqlparameter("@ joindate",sqlDB Type.datetime)
idparam.value=t xtID.text
dtparam.value=d oj.toShotdatest ring()

conn.open()
dbcommand=new sqlcommand(qry, conn)
dbcommand.param eters.add(idpar am)
dbcommand.param eters.add(dtpar am)
dbcommand.execu tenonquery()
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=t xtID.text

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

On Mon, 1 May 2006 02:37:01 -0700, Rajani
<Ra****@discuss ions.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=d oj

Cheers,

Greg
"Rajani" <Ra****@discuss ions.microsoft. com> wrote in message
news:6D******** *************** ***********@mic rosoft.com...
> Hello,
>
> I replaced the calendar control to 3 dropdownlists(d ay,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,joindat e datetime)
>
> i am getting the date selected as
>
> dim doj as new
> datetime(yr.sel ectedValue,mnth .selectedvalue, dy.selectedvalu e)
>
> qry="insert into staff(empid,joi ndate) values(@empid,@ joindate)"
> dim idparam as new sqlparameter("@ empid",sqlDBTyp e.integer)
> dim dtparam as new sqlparameter("@ joindate",sqlDB Type.datetime)
> idparam.value=t xtID.text
> dtparam.value=d oj.toShotdatest ring()
>
> conn.open()
> dbcommand=new sqlcommand(qry, conn)
> dbcommand.param eters.add(idpar am)
> dbcommand.param eters.add(dtpar am)
> dbcommand.execu tenonquery()
> 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
9305
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 three dropdow boxes for hours, minutes, and AM/PM. All of these need to be considered together and converted to one Unix Timestamp and then inserted to the MYSQL date field. The type of field is INT (11) so that I can instead of the standard...
0
1480
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 time and date. When a row has been selected for editing I want to be able to click a button in the datagrid and update one of the text boxes with the current time and date. All the code for editing rows and getting the current time and date when...
15
18894
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 the value in timeonly format by using this command Format(now,"HH:mm:ss") But when I insert it into the Sql Server database, it embadded date value with it. the output looks like that "01/01/1900 08:59:00" in that case time is
0
1239
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 number formats.However we are currently facing a problem that say a user in Italy uses our product and user's settings have a "." as a time seperator sql server is unable to insert such time values into the database.We get an error for date-time...
1
1652
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 WITHOUT ' IF I AM GIVING ' THEN GETTING ERROR DATE CONVERSION CHAR TO DATE TIME IT IS URGENT PLEASE HELP!!!!!
6
3307
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 "2:50:54 PM". But after the row is inserted and I check the data in the database, the column data is set to "1/7/2007 2:50:04 PM" (notice today's date in front of the time). If I insert data directly into the table in the Enterprise Manager, the...
13
3053
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
3019
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 file is to be read into my java program and then inserted (from the program into an Access Database). I am not exactly sure of where the problem lies. I know it has something to do with how I am parsing the file, or how I am passing my arguments to...
0
2904
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 htmLength=0; public DBParam(String c,String k) //k has the data of html { this.inputStream=getStreams(k); this.htmlLength=k.length();
2
3097
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 section: Discography --------------------- DiscID
0
9479
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10080
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8967
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7492
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6733
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5509
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4043
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3639
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.