0

I have a datepicker textbox as below:

   <input type="text" id="txtdob" class="datepicker" style="width:154px"/>

I am not able to pass the value from this datepicker to my database table.Everything works fine so i am not going to post the entire code here.I am passing the value as below:

  cmd.Parameters.AddWithValue("@DOB", txtdob.value);

But it says could not find txtdob.Any help will be appreciated.

RelatedRhymes
  • 428
  • 6
  • 26
  • This has been previously asked: http://stackoverflow.com/questions/8904895/inserting-datetimepicker-value-to-sql-server-2008 – TTeeple Apr 01 '15 at 15:35
  • Yes i have been through the above link before posting this question.Apparently, cmd.Parameters.Add("@DOB",SqlDbType.DateTime).Value=txtdob.Value; doesnt work and still throws the same error. @TTeeple – RelatedRhymes Apr 01 '15 at 15:47
  • 1
    This looks more like what you want: http://stackoverflow.com/questions/425870/using-datetime-in-a-sqlparameter-for-stored-procedure-format-error/425896#425896 – TTeeple Apr 01 '15 at 15:54
  • The problem is in your .net code, not your SQL. You should re-tag the question accordingly. – Tab Alleman Apr 01 '15 at 18:10

2 Answers2

0

try this

cmd.Parameters.Add(New SqlParameter("@DOB",Data.SqlDbType.DateTime))
cmd.Parameters("@DOB").Value = txtdob.value;
M.Ali
  • 67,945
  • 13
  • 101
  • 127
  • No.it doesnt work.A lot of erros in the above statment.'New' does not exist in the current context.cmd.Parameters cannot be used as a method and still txtdob cannot be found – RelatedRhymes Apr 01 '15 at 15:44
0

I finally figured it out.I just had to include runat=server to my textarea input.I knew this was a silly mistake but my question was right on point.

RelatedRhymes
  • 428
  • 6
  • 26