|
I use sql server 2000 with c# and I have made a database table name administrator which consist of three field (a_id,user_name,password).I also entered the data into it from the sql query.I have made the form that the user can input user_name and passord. I have already fetched the data from database table and I need to update the database table fields. how can i do.
|
|
|
|
|
Replace the SQL that is selecting the data, with SQL that inserts the new data
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
hi guy
can any bodey help me our i want to turn off my ups through my dot net application,
any help code , link .
thanks in advance
hello
|
|
|
|
|
The manual that came with the UPS is what you need. if it doesn't say that it offers that sort of functionality, then you probably cannot do it
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Any one know where I can find information, I could not Google any thing.
It's a font name.
|
|
|
|
|
I think it's more of a corrupted font name. It's impossible to say which one it really is.
|
|
|
|
|
Hi All,
I am using C# 2.0. I have a form with few controls such as Panel, TextBox, ListBox, GridView and etc. I am trying to resize all the controls in runtime when user resize the form by dragging form borders and I am doing this by setting Anchor property of all the controls to all sides (right,left,top,bottom) and the Dock property = None. Everything works fine ,but if I set form property AutoScroll = true then controls doesn’t resize. Any idea why? Please help.
Thanks in advance!
A.Asif
|
|
|
|
|
BEcause it scrolls instead of sizing ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I have an application that needs to record data in a database and the particular date when that data was written to the database. More, I need customers to be able to retrieve data from the database by date or date range. To that end, the MS Access database I'm using has a field called TestDate of type Date/Time, and I set up two date/time pickers to allow customers to select a date or date range from which to get data.
All this works well and good until I change my regional/language options so the date format changes, say from mm/dd/yyyy to dd/mm/yyyy. Then, although the MS Access database updates the TestDate data automatically to reflect the change in date/time format and my date/time pickers in the C# appilcation reflect the altered format, the result of executing SQL statements based on the date/time pickers does not return the correct data from the database.
Rather, selecting all data from December 10, 2007 retrieves data from October 12, 2007. By contrast, if I select, say November 29, 2007, the correct data is returned. Something, then, is getting confused about ambiguous dates.
Any suggestions would be appreciated.
|
|
|
|
|
You are storing using DateTime fields from the textboxes aren't you, rather than using a string? More importantly, you are using a parameter to put the field into the database aren't you?
If you want to force a UTC date, then you use the U format qualifier with the DateTime. For example
DateTime dt = DateTime.Now;
Console.WriteLine(dt.ToString("U"));
|
|
|
|
|
Yes, I am using a parameterized query to insert new records into the database and storing the data using the DateTime data type rather than a string.
Still, somewhere between picking the datetime for the SELECT statement and retrieving the data from the database, the date time format gets lost in translation. If I select a non-ambiguous date such as 13/09/2007 (September 13, 2007), execution of the SQL command returns the correct data, but selecting an ambiguous date, such as 3/12/2007 (intending December 3, 2007) returns erroneous data. The report shows 12/3/2007 (March 12, 2007), but the value of the date prior to the execution of the SQL statement is 3/12/2007 (December 3, 2007).
|
|
|
|
|
Hi, I'm learning C# by lurking the forums, but have much experience in Access. This solution works in Access, and I think it will work in C# but haven't tested yet.
In an Access query you have to enclose the date in # to force american date format.
This is how I do this (In Access)
Function ScriptaUDF(Datum As Date)
ScriptaUDF = "#" & Trim(Str(Month(Datum))) & "/" & Trim(Str(Day(Datum))) & "/" & Trim(Str(Year(Datum))) & "#"
End Function
So whenever I need a date in a query I use:
where (((Table.datefield) = " & ScriptaUDF(Me!Datefield) & "))
I hope this helps
|
|
|
|
|
That's interesting. The problem I've been having occurs, seemingly, during the execution of the SQL statement. I enclose my SQL SELECT statements with a # sign currently, so
"SELECT * FROM Table WHERE Date BETWEEN #" startdate #" AND #" endate"
If the # character forces an American date format, that would explain much, I think.
|
|
|
|
|
How would I specify a date in a SQL expression without forcing the american date format? Is there something I can use to insert a date in the SQL query without using the # sign? Or, if I use the # sign, can I simply force the format that is needed?
|
|
|
|
|
I found a solution. Basically, the Jet Engine seems to have problems with translation. To get the correct data, I have to do this:
SELECT * FROM TABLE WHERE Date BETWEEN Format(#" + startDate + "#,'mm/dd/yyyy')AND Format(#" + endDate + "#,'mm/dd/yyyy')
By setting the format in the SQL statement to United States format, the data seems to come back to me correctly.
|
|
|
|
|
If I have a text file containing the first line like this:
John 1976 200,000 United States
How do I import it to the database specifying that the first column should be John, second is 1976, third is 200,000, and last column is United States?
What are the commands/syntax being used to achieve this? Thanks.
|
|
|
|
|
Your text file format is a disaster. So long as country is the only field that can have a space in it, you may be OK. You use the string.Split method to turn this into a string array. If there's a fifth or sixth element, you append those to the fourth ( that's the country ). Then you have values to stuff into the database.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks. How do we use bcp or bulk insert to import the data in text file into the database? I haven't done anything with databases or ADO.Net so I might need some step by step procedure to do this.
|
|
|
|
|
In that case, I'd recommend going through an article on the topic, on this site or elsewhere. It's just going to cover things in far more depth and clarity than I can hope to do in a forum reply.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I answered a question a few posts ago, where a user thought that assigning reference types was creating aliases for the names of those types. After thinking about it, I began to wonder if there IS a way to do this, so that you have two instances referencing the same pointer to the object. For example, is there a way to do the following in C# (I doubt it, because it was often the cause of many problems in C++, but just thought I would ask)?
object A = new object();
object B = ref A;
B = new object();
Hope this question makes sense. Thanks,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Hi Jeff,
I have never seen such thing, so AFAIK it is impossible.
Also, IMO the C# language designers would consider it unnecessary and unsafe.
And if you look at pointers, they can only point to value types.
So I think you will have to refactor the code and substitute every B by A.
[added]
the feature you're asking about is similar to the union in C/C++;
it is not supported in C#, although there is a way to mimic it inside structs,
by giving explicit FieldOffset values
I use unions (in C that is) only to byte-convert from one type to another, not to get two names for
the same thing; sometimes I miss it in C#. Not sure how the C# compiler would cope with the latter.
[/added]
modified on Tuesday, December 11, 2007 2:49:59 PM
|
|
|
|
|
Yeah, I remembered doing it in C++ before, but couldn't remember what the keyword was. I don't really have a need (nor see a need) to do this, since, as you said, I could just substitute the variable A for all occurances of B and still have identical code. This is a feature that I think should NOT have been implemented in C#, so I am glad to see that it isn't. Thanks Luc,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
After googling for a while, I determined that the code I was refering to in C++ would have looked something like this (I think)...
int i = 0;
int j = &i;
j = 5; I think that the previous code forces i and j to always be equivalent, but again, it has been a while since I programmed in C++, so I can't be certain. Thanks,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Skippums wrote: int j = &i;
that would not compile, it should be int* j = &i; so there is only a single
int, and a pointer that now points to the same int. So changing it either with i=...
or with *j=... results in changing the single int, whatever way you access it,
it is still a single variable.
|
|
|
|
|
I was wondering if there is a simple number format code for if you only want to see the decimal portion of the number if there are any significant digits to the right of the decimal - otherwise show the number as an integer.
ex. 3.5 -> 3.5 and 3.0 -> 3 (instead of 3.0)
Thanks
Brent
|
|
|
|