|
Assuming that dtTime is properly converting to a value within the query that mySQL understands ( that is, that the default toString() does what you need ), and assuming that 'Data >=' is a typo above, and Date is being checked in both instances, this will only return rows where the Date column is equal to or greater than the moment when you make the query. If dtTime2 also = DateTime.Now, the odds of a match drop sharply.
Assuming this is dummy code to show the basic approach, I'd suggest you need to open a table in mySQL and see how it stores the dates, then format your datetime to be the same. It's probably YYYYMMDD:HHMMSSSS, assuming that time is also stored. The DateTime class has a property to return a string in this format, but it's name escapes me right now.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
so simply i've just to do this?
date >= dtTime.ToString()
|
|
|
|
|
my date type is a generic date type composted by:
30/11/2005 12.04.03
day/month/year hours/minutes/seconds.
i've tried to looking something insite DateTime struct, but nothing about this type.
anyway it is compoused by:
myOra.ToLongTimeString() + myOra.ToShortDateString()
how can i do?
Please help me, tnx.
|
|
|
|
|
i've tried also with this but nothing:
Data >= " + myOra.ToLocalTime().AddHours(myOra.Hour)
|
|
|
|
|
Try using parametized queries. That will make you not have to deal with date formats, and also prevent SQL injection attacks.
This is an example the the OLE DB .NET provider. You'll have to search for mySQL, but definitely possible:
string sql = "SELECT * FROM Table WHERE ID = ?";
OleDbCommand cmd = new OleDbCommand(sql, conn);
cmd.Parameters.Add("ID", id);
using(OleDbDataReader rdr = cmd.ExecuteReader()) .............. With OleDbCommand , you must supply all parameters in the order they appear in the query. In SqlCommand (for SQL Server) parameteres are named and you can supply them in any order. Check your docs for the mySQL data provider.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
|
And only if you knew that I was going to post a link to your article, but I was too lazy to go find its URL....
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
i need to delete a row by checking the ID (auto number primary key) using the following code;
query = "DELETE * FROM myTable WHERE ID = '" + id + "'";
i get an exception: data types not corresponded.
I guess it depend by the id data type, i've tried to declare it as int, uint, long, ulong but i get always the same exception.
Please help me, tnx.
|
|
|
|
|
|
|
simply id is a long numner so it donesn't need about ' '. so:
ID = id; is correct
|
|
|
|
|
Again, I'll recommend parametizes queries for many reasons. See my reply to your thread above.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Try out these one i think it will work for u
query = "DELETE * FROM myTable WHERE ID = " + id ;
if not contact me (ravikim2001@yahoo.co.in)
ok bye.
Happy coding
|
|
|
|
|
|
how can i insert the picture to the sqldatabase ?what datatype cani use ?
how can i load the picture to the database?can you give me the code with c#.net to insert picture from the webform.asp to the sqldatabase?
|
|
|
|
|
|
My boss would like make peer evaluations done on an electronic basis, he needs each employee to fill out a form like:
-your name "tom"- -person being evaluated's name "bob"-
q1 - response
q2 - response
ect...
The admin should then be able to do a search for "bob" and then a summary report will be made with the questsions asked and every ones responses about "bob"
q1 - "bill's response"
- "tom's response"
but none of the submitted reports should be accesible to other users besides the admin. So how can one submit something then not have access to it? i know its a simple problem but.... gah..
|
|
|
|
|
I would have thought this would be an application level thing rather than a database level thing.
Each user would be allowed to create an edit their own rows via the application. The application would only permit them to see data that they entered. Admin users (in this instance, however, it sounds more like managerial users) would be able to see everything.
Each row would contain the username of the person that created it. The application that is interacting with the database would contain in the WHERE clause the necessary filter, e.g. WHERE username = @loggedOnUser
Ian McCloy wrote:
So how can one submit something then not have access to it? i know its a simple problem but.... gah..
This sounds crazy. But you could:
GRANT INSERT ON [table_name] TO [user]
REVOKE SELECT ON [table_name] TO [user]
or if you are accessing only through stored procedures, then you only provide access to stored procedures that permit the data to be inserted.
Personally, I would say it is always better for a user to be able to review and edit their own work. For example, I don't like forums where I cannot edit my posts (I often modify a post to correct spelling errors that I didn't pick up on the first time)
My: Blog | Photos | Next SQL Presentation
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
Can I use the Same Table structures, triggers, sprocs and UDF's that was developed in SQL 2000 in YUKON.
Is Migration Simple?. Or Do i have to change some code.
If yes how much.
Thanks in Advance
Ashok
|
|
|
|
|
I can't imagine why you'd have to change anything particularly
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
do u mean Just taking the databases from 2000 to yukon will work?
|
|
|
|
|
I mean that I would expect that to be the case, yes. I'm not saying I've tried it, but they're not going to change T-SQL to make old stuff stop working, surely ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
How to insert text in MEMO field?
(I'm using Access DB and VS2003)
|
|
|
|
|
Hello,
I am currently porting software for my University from MSSql to MySql. I am having some problems and would really appreciate any help you could give.
I am unable to change the core design of the database tables because another student is working on software to process the resulting data, and he is hard coding everything. I have expressed how this is a bad design idea, but to no avail. So I am stuck with the current design.
In this design, the tables use a varchar(8000) as a primary key for relating the tables. This is automagically cast into a TEXT field by MySql, and it of course throws the error that a TEXT field as a primary key must have an index. I went ahead and gave indexes to all those text fields and everything on that part works great.
However, later in the database creation there are some constraint commands put on these tables that use those TEXT fields as the foreign key, and when it sees that this foreign key is a TEXT field it throws an error that a lenght must be specified.
I have no idea (after reading the manual again) how to specify a length in the constraint command. If you know how please let me know, I can post the code if that would help.
Thanks
Tim Reynolds
|
|
|
|
|
razialx wrote:
from MSSql to MySql.
Why do you need to do this ? If it's a cost issue, have you looked into MSDE ?
razialx wrote:
In this design, the tables use a varchar(8000) as a primary key for relating the tables.
Your co student is an idiot. I can't think of a worse design, no matter how hard I try. I'd urge you to distance yourself from this cowpat of a project ASAP. A primary key is an index, it needs to be easy to search. A varchar(8000) is about as far from that as you can get.
Christian Graus - Microsoft MVP - C++
|
|
|
|