Ok.......... I'm trying to fill a parameterized table onto a Dataset
via a sqlDataAdapter. It works fine if I fill the Dataset with all
the column fields. What I want to do though is to only fill the
Dataset with certain values from my DateTimeIn column (i.e. only files
where DateTimeIn == user-defined date). This isn't working.
I'm sure my query is correct because I've used the same code in
different projects:
SELECT TransIdentity, DateTimeIn, DateTimeOut, RevisedDate FROM
TransactionData WHERE (DateTimeIn = @Param2)
What I think it is is that the user-inputed date is not being read
right as a parameter. Does it matter that the txtDateParameter.Text
is not in DateTime format? I don't think so.
private void btnShow_Click(object sender, System.EventArgs e)
{
sqlDataAdapter1.SelectCommand.Parameters["DateTimeIn"].Value =
txtDateParameter.Text;
dsTimeIn1.Clear();
sqlDataAdapter1.Fill(dsTimeIn1);
}
Can someone help me out, I can't figure out what's going on.
Let me know if you need some more info.
Thanks guys,
Frustrated Mike 4 2911
Hi Michael,
Some observations:
a) You should add the Parameter object to the Command's Parameters
collection first and then specify its value second (not sure this is a
necessary step but at least it has always worked for me that way).
b) If you specify the parameter as @Param2 in the SQL, it should be named
the same in the Command's Parameters collection.
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"Michael Jones" <ep*****@yahoo.com> wrote in message
news:be**************************@posting.google.c om... Ok.......... I'm trying to fill a parameterized table onto a Dataset via a sqlDataAdapter. It works fine if I fill the Dataset with all the column fields. What I want to do though is to only fill the Dataset with certain values from my DateTimeIn column (i.e. only files where DateTimeIn == user-defined date). This isn't working.
I'm sure my query is correct because I've used the same code in different projects:
SELECT TransIdentity, DateTimeIn, DateTimeOut, RevisedDate FROM TransactionData WHERE (DateTimeIn = @Param2)
What I think it is is that the user-inputed date is not being read right as a parameter. Does it matter that the txtDateParameter.Text is not in DateTime format? I don't think so.
private void btnShow_Click(object sender, System.EventArgs e) { sqlDataAdapter1.SelectCommand.Parameters["DateTimeIn"].Value = txtDateParameter.Text; dsTimeIn1.Clear(); sqlDataAdapter1.Fill(dsTimeIn1); }
Can someone help me out, I can't figure out what's going on.
Let me know if you need some more info.
Thanks guys,
Frustrated Mike
Yes I did do that. Thanks Dmitriy. I don't understand what's going
on. No error or inforamtion comes up when I try to preview the data
via the DataAdapter. And, when the application is running and I hit
my Submit button, I get a System.IndexOutOfRangeException where I set
my parameter equal to the textbox text. This happens no matter what
kind of information I input in the textbox. Here's where it errors:
private void btnShow_Click(object sender, System.EventArgs e)
{
********** sqlDataAdapter1.SelectCommand.Parameters["DateTimeIn"].Value
= txtDateParameter.Text;
dsTimeIn1.Clear();
sqlDataAdapter1.Fill(dsTimeIn1);
}
Any idea?................thanks again
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote in message news:<OQ**************@TK2MSFTNGP11.phx.gbl>... Hi Michael,
Some observations:
a) You should add the Parameter object to the Command's Parameters collection first and then specify its value second (not sure this is a necessary step but at least it has always worked for me that way). b) If you specify the parameter as @Param2 in the SQL, it should be named the same in the Command's Parameters collection.
-- Dmitriy Lapshin [C# / .NET MVP] X-Unity Test Studio http://x-unity.miik.com.ua/teststudio.aspx Bring the power of unit testing to VS .NET IDE
"Michael Jones" <ep*****@yahoo.com> wrote in message news:be**************************@posting.google.c om... Ok.......... I'm trying to fill a parameterized table onto a Dataset via a sqlDataAdapter. It works fine if I fill the Dataset with all the column fields. What I want to do though is to only fill the Dataset with certain values from my DateTimeIn column (i.e. only files where DateTimeIn == user-defined date). This isn't working.
I'm sure my query is correct because I've used the same code in different projects:
SELECT TransIdentity, DateTimeIn, DateTimeOut, RevisedDate FROM TransactionData WHERE (DateTimeIn = @Param2)
What I think it is is that the user-inputed date is not being read right as a parameter. Does it matter that the txtDateParameter.Text is not in DateTime format? I don't think so.
private void btnShow_Click(object sender, System.EventArgs e) { sqlDataAdapter1.SelectCommand.Parameters["DateTimeIn"].Value = txtDateParameter.Text; dsTimeIn1.Clear(); sqlDataAdapter1.Fill(dsTimeIn1); }
Can someone help me out, I can't figure out what's going on.
Let me know if you need some more info.
Thanks guys,
Frustrated Mike
Michael,
It seems you are trying to access the parameter named DateTimeIn while you
have a parameter named @Param2 in the query. Next, you might set a
breakpoint on the following line: sqlDataAdapter1.SelectCommand.Parameters["DateTimeIn"].Value = txtDateParameter.Text;
and ensure the Parameters collection really contains this parameter. Even
more, you should explore this collection in the Watch window to find out if
there are any parameters at all and what are their names.
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
"Michael Jones" <ep*****@yahoo.com> wrote in message
news:be**************************@posting.google.c om... Yes I did do that. Thanks Dmitriy. I don't understand what's going on. No error or inforamtion comes up when I try to preview the data via the DataAdapter. And, when the application is running and I hit my Submit button, I get a System.IndexOutOfRangeException where I set my parameter equal to the textbox text. This happens no matter what kind of information I input in the textbox. Here's where it errors:
private void btnShow_Click(object sender, System.EventArgs e) { ********** sqlDataAdapter1.SelectCommand.Parameters["DateTimeIn"].Value = txtDateParameter.Text; dsTimeIn1.Clear(); sqlDataAdapter1.Fill(dsTimeIn1); }
Any idea?................thanks again
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:<OQ**************@TK2MSFTNGP11.phx.gbl>... Hi Michael,
Some observations:
a) You should add the Parameter object to the Command's Parameters collection first and then specify its value second (not sure this is a necessary step but at least it has always worked for me that way). b) If you specify the parameter as @Param2 in the SQL, it should be
named the same in the Command's Parameters collection.
-- Dmitriy Lapshin [C# / .NET MVP] X-Unity Test Studio http://x-unity.miik.com.ua/teststudio.aspx Bring the power of unit testing to VS .NET IDE
"Michael Jones" <ep*****@yahoo.com> wrote in message news:be**************************@posting.google.c om... Ok.......... I'm trying to fill a parameterized table onto a Dataset via a sqlDataAdapter. It works fine if I fill the Dataset with all the column fields. What I want to do though is to only fill the Dataset with certain values from my DateTimeIn column (i.e. only files where DateTimeIn == user-defined date). This isn't working.
I'm sure my query is correct because I've used the same code in different projects:
SELECT TransIdentity, DateTimeIn, DateTimeOut, RevisedDate FROM TransactionData WHERE (DateTimeIn = @Param2)
What I think it is is that the user-inputed date is not being read right as a parameter. Does it matter that the txtDateParameter.Text is not in DateTime format? I don't think so.
private void btnShow_Click(object sender, System.EventArgs e) { sqlDataAdapter1.SelectCommand.Parameters["DateTimeIn"].Value = txtDateParameter.Text; dsTimeIn1.Clear(); sqlDataAdapter1.Fill(dsTimeIn1); }
Can someone help me out, I can't figure out what's going on.
Let me know if you need some more info.
Thanks guys,
Frustrated Mike
Yes I did do that. Thanks Dmitriy. I don't understand what's going
on. No error or inforamtion comes up when I try to preview the data
via the DataAdapter. And, when the application is running and I hit
my Submit button, I get a System.IndexOutOfRangeException where I set
my parameter equal to the textbox text. This happens no matter what
kind of information I input in the textbox. Here's where it errors:
private void btnShow_Click(object sender, System.EventArgs e)
{
********** sqlDataAdapter1.SelectCommand.Parameters["DateTimeIn"].Value
= txtDateParameter.Text;
dsTimeIn1.Clear();
sqlDataAdapter1.Fill(dsTimeIn1);
}
Any idea?................thanks again
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote in message news:<OQ**************@TK2MSFTNGP11.phx.gbl>... Hi Michael,
Some observations:
a) You should add the Parameter object to the Command's Parameters collection first and then specify its value second (not sure this is a necessary step but at least it has always worked for me that way). b) If you specify the parameter as @Param2 in the SQL, it should be named the same in the Command's Parameters collection.
-- Dmitriy Lapshin [C# / .NET MVP] X-Unity Test Studio http://x-unity.miik.com.ua/teststudio.aspx Bring the power of unit testing to VS .NET IDE
"Michael Jones" <ep*****@yahoo.com> wrote in message news:be**************************@posting.google.c om... Ok.......... I'm trying to fill a parameterized table onto a Dataset via a sqlDataAdapter. It works fine if I fill the Dataset with all the column fields. What I want to do though is to only fill the Dataset with certain values from my DateTimeIn column (i.e. only files where DateTimeIn == user-defined date). This isn't working.
I'm sure my query is correct because I've used the same code in different projects:
SELECT TransIdentity, DateTimeIn, DateTimeOut, RevisedDate FROM TransactionData WHERE (DateTimeIn = @Param2)
What I think it is is that the user-inputed date is not being read right as a parameter. Does it matter that the txtDateParameter.Text is not in DateTime format? I don't think so.
private void btnShow_Click(object sender, System.EventArgs e) { sqlDataAdapter1.SelectCommand.Parameters["DateTimeIn"].Value = txtDateParameter.Text; dsTimeIn1.Clear(); sqlDataAdapter1.Fill(dsTimeIn1); }
Can someone help me out, I can't figure out what's going on.
Let me know if you need some more info.
Thanks guys,
Frustrated Mike This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Steven Blair |
last post by:
Hi,
Here is a short decsription of my problem.
I have written a dll for Database accessing. I have one method which can
return a Dataset and another method which takes a Dataset and upates a...
|
by: goodstart123 |
last post by:
For example, the following code works fine without SqlConnection.
Any Answer to the question?
string connectionString =
"server=YourServer; uid=sa;
pwd=YourPassword;...
|
by: Fernando |
last post by:
I am having problems with updating the changes done over a DataSet to a
Database.
All the changes being done using the Form are stored in the Dataset, but
when i decide to close the Form and open...
|
by: LP |
last post by:
Hello,
In the past I used SqlCommandBuilder and SqlDataAdapter .Update method to
apply changes in a DataTable back to its table source in SQL Server. It
worked fine when DataSet had only 1...
|
by: Victor |
last post by:
Hello there,
I have a module in VB.NET (ASP.NET) and on top I declare the
SqlConnection and the SqlDataAdapter.
Like:
Module AccessDB
Dim sqlCmd As New SqlCommand
Dim conAanvraag As New
|
by: Matt Jensen |
last post by:
Howdy
Fairly simple question I think, I presume the answer is no it can't be
reused for 2 *SELECT* statements, but just hoping for clarification. Just
asking in the interests of trying to minimise...
|
by: herlihyboy |
last post by:
I have searched and can't find any articles pertaining to this issue...
I am filling a dataset using a SqlDataAdapter that was instantiated
with a SqlCommand object. When the Fill method is...
|
by: Spectre1337 |
last post by:
Hello,
I've encountered a rather puzzling problem with SqlDataAdapter. I've set up a number of elaborate tables in the Microsoft SQL Server Management Studio Express (including several table key...
|
by: Baudin |
last post by:
Hallo all,
I have the following problem. I'm trying to fill a DataTable in a DataSet
with data from an SQL server 2000 database.
I create a SqlConnection, SqlCommand and finally an...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
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...
|
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...
| |