Inserting date problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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,

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

what could be the problem?
 
What about this line:
idparam.value=txtID.text

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