473,387 Members | 3,787 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,387 software developers and data experts.

search a record in sql table using a datetime variable from C sharp

Hello there,

I have a problem.I have an application in C sharp that searches for a record in a sql database using a datetimepicker,the output is displayed in a datagridview.When I execute it I got a blank datagridview with empty columns.I can not view the content and I don't get any error message.Can you help?

Thank you in advance.


Here is my code:

Expand|Select|Wrap|Line Numbers
  1. DataTable dt=new dataTable();
  2. SqlDataAdapter sda=new sqldataadapter("select * from Delivery where convert(char(20),Delivery_Date,112)='"+ dateTimePicker1.value.Date,con);
  3. //con is sqlconnection
  4. Sda.Fill(dt);
  5. Datagridview1.DataSource=dt;
Jan 1 '14 #1
1 1229
Rabbit
12,516 Expert Mod 8TB
You didn't put a closing quote around your date value.
Jan 1 '14 #2

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

Similar topics

2
by: LVande | last post by:
SQLLY challenged be gentle -- Trying to create code that will drop a table using a variable as the Table Name. DECLARE @testname as char(50) SELECT @testname = 'CO_Line_of_Business_' +...
4
by: Michael C# | last post by:
Given a DateTime variable, what's the best way to check "minor" status (i.e., less than age 18 years) based on today's date? I came up with this: Dim minor As Boolean = true 'dtDOB is a...
2
by: Solution Seeker | last post by:
Hi, I need a solution to assign a Null to a Datetime Variable / Object. Am willing to know whether it is possible? I will appreciate you if any one knows the solution for it . The...
1
by: William Herring | last post by:
I would like to create a temporary table with a variable name. For example, the name of the table might be based on some form of datetime and a constant text. I have looked through the logs, but...
2
by: tshad | last post by:
I can't seem to get the Date portion of a datetime variable put into a string: I tried: DateTime dateTime; dateTime = Convert.ToDateTime(dr).Date; stemp = Convert.ToString(dateTime); This...
1
by: B | last post by:
Hello All, This is my first time using this list, but hopefully I got the right one for the question I need to ask :). I have a table which has about 4 million records. When I do a search...
6
by: tallman21 | last post by:
Apologies if this is a duplicate thread, didn't come across the answer after searching. As part of the database closing process, I'd like to add in code that automatically exports my main data...
1
by: jane2007 | last post by:
Hello, Here is my current code ... Dim rstStk As Recordset Set rstStk = CurrentDb.OpenRecordset("Select * from stk where PartNum = '" & strPrt & "'") The problem with this code is that i...
5
by: James | last post by:
Hello, I am a beginner in C# programming and I just want to know how we can pass a datetime variable in a method. can anyone please help me regarding this. Thanks, James.
3
by: dmorand | last post by:
I'm very new to stored procedures so this is probably something very dumb. I want to pass a name of a table to be created to my stored procedure. I'm using the variable @tableName in the code below...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.