473,383 Members | 1,952 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,383 software developers and data experts.

"Failed to convert parameter value from a SqlParameter to a DateTime." & no solution

1
when i run my code i get this error message
"Failed to convert parameter value from a SqlParameter to a DateTime."

& i couldn't find what is wrong..... here's my code

Expand|Select|Wrap|Line Numbers
  1.  
  2. protected void Button1_Click(object sender, EventArgs e)
  3.     {
  4.       SqlConnection thisConnection = new SqlConnection  
  5.       (thisConnectionString);
  6.         DataSet thisDataSet = new DataSet();
  7.         thisConnection.Open();  
  8.         DateTime from= new DateTime();
  9.         DateTime to = new DateTime();
  10.         from = DateTime.Parse(TextBox1.Text);
  11.         to = DateTime.Parse(TextBox2.Text);
  12.         ReportViewer1.Visible = true;
  13.  
  14.         SearchValue[0] = new SqlParameter 
  15.            ("@datefrom",SqlDbType.DateTime);
  16.         SearchValue[0].Value = from;
  17.  
  18.         SearchValue[1] = new SqlParameter("@dateto",
  19.             SqlDbType.DateTime);
  20.         SearchValue[1].Value = to;
  21.  
  22.         ReportViewer1.LocalReport.ReportPath 
  23.            ="Report.rdlc";
  24.  
  25.         thisDataSet = SqlHelper.ExecuteDataset
  26.       (thisConnection, "GetAllMissingItems",SearchValue);
  27.  
  28.         ReportDataSource datasource = new 
  29.         ReportDataSource("BA2DataSet_GetAllMissingItems",
  30.               thisDataSet.Tables[0]);
  31.  
  32.         ReportViewer1.LocalReport.DataSources.Clear();
  33.         ReportViewer1.LocalReport.DataSources.Add
  34.              (datasource);
  35.         ReportViewer1.LocalReport.Refresh();
  36.         }
  37.  
  38.  
and my 2 parameters in the stored proceduers are
@datefrom datetime, @dateto datetime

thx in advance
Jul 5 '10 #1
0 1357

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Laszlo Csabi | last post by:
Hi Folks, Can someone explain me why I'm getting the following error? The error message I got is : "Parameter count does not match Parameter Value count."
3
by: Ian Lazarus | last post by:
// why is the error message being generated? // Microsoft Visual C/C++ 5.0 class Bar { public: void Log(const char* p){ } }; class Foo : public Bar
7
by: Scott W Gifford | last post by:
Hello, I'm considering using XML to represent a stream of location information, and XPath to do queries against it. I've got most of it figured out (at least on paper), but I can't figure out...
9
by: Igor Okulist | last post by:
int func(void**); { short* p = NULL; func(&p); //<<< here } Could somebody remind me why is this not allowed ? error message: "cannot convert parameter from 'short **' to 'void **'"
2
by: Oenone | last post by:
In our applications, we use the special value of DateTime.MinValue to represent "null dates" throughout all our code. We recently ran into an issue where we wanted an optional date parameter for a...
1
by: stillh2os | last post by:
Hello. I'm new to .NET, and I'm trying to implement a callback function. I want my managed C++ code to call an unmanaged function, passing in a callback function that the unmanaged C/C++ code...
3
by: Darin | last post by:
I have a problem I just can't figure out. I have a form with a subform, and the recordsource of the subform has criteria based on some unbound fields in the parent form so that data in the parent...
3
by: Sugandh Jain | last post by:
Hi, I am using property like this.. private DateTime? _propName; public DateTime? PropName { get { return _propName; }
0
by: Radu | last post by:
Hi. I have finished a web-site - and it runs fine on my dev machine. I have deployed it onto the server, and now I have this (which, by the way, doesn't seem to happen all the time - sometimes I...
1
by: niharnayak2003 | last post by:
Hi All, I am facing the problem in Typecast inside the Generic class. I need a function which will take two param 1:-Xpath 2:- XMLDOC and return me what i will need. here is the code for...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...

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.