|
Bernhard Hofmann wrote:
From what I've read, you should be using the Date OleDbType (DBTYPE_DATE), which "maps" to a System.DateTime. The DBTYPE_DATE is a double, with
This is my select cmd:
SELECT ID, Recv, Send FROM RateLog WHERE (ID > ?)
this.oleDbSelectCommand1.Parameters.Add(
new System.Data.OleDb.OleDbParameter("ID", System.Data.OleDb.OleDbType.DBDate, 0, "ID"));
where "ID" is the timestamp field.
Then I would pass DateTime.Now.AddHours(-3) for example.
All in C# in MyDUMeter.
MyDUMeter: a .NET DUMeter clone
|
|
|
|
|
I am trying to figure out how do to a bulk insert from C#.
Can any one help me?
Darryl Borden
Principal IT Analyst
darryl.borden@elpaso.com
|
|
|
|
|
What about doing a bcp by calling a SQL script/T-SQL statement as per usual?
Would that be OK?
Cheers,
Simon
"The day I swan around in expensive suits is the day I hope someone puts a bullet in my head.", Chris Carter.
animation mechanics in SVG
|
|
|
|
|
The problem with that is that the project manager wants error checking and doesn't want the program hosed because there was a problem with bcp.
Apparently, in C++, there is a way to open the database connection for what is called a fast insert. I can't find any documentation on this but was hoping someone has done this kind of thing in c#.
dpb
Darryl Borden
Principal IT Analyst
darryl.borden@elpaso.com
|
|
|
|
|
Look up the IRowsetFastLoad interface.
I used it it C++ a while back, not sure if you can get to it from C#, or if there is a similar/simpler way of doing this in .NET.
Unfortunately, I lost my code, so I cannot be much more help than this.
Bruce Duncan, CP#9088, CPUA 0xA1EE, Sonork 100.10030 I can levitate birds...
|
|
|
|
|
Hi, i´m new to ADO.NET and i have a couple of questions.
Is there any way to automatically make an insertion using windows forms?
I can make the user enter the data and add a row to the data set, or add a row using the method on the dataview. But in this way i have to keep all the UI logic by myself, because the controls don´t update their content.
Gabriel
Old C programmers never die. They just cast into void
|
|
|
|
|
We have a project which started as a "pure" Access application. Access front end and Access back end.
However the app got popular and the Access BE could not handle it all. So the FE stayed the same but the BE was converted to SQL.
There are still problems though. Namely even in a development environment with a fresh machine and nobody else accessing the application, record locks occur.
Does anyone know anything about doing this kind of conversion and whether it is a good idea to have an Acess FE and SQL BE? Here is some of the apps code, the recordset opening bit, is it correct?:
Set db = CurrentDb
Set rsConcession = db.OpenRecordset(strSQL, dbOpenDynaset, dbSeeChanges)
With rsConcession
.Edit
!LinkNo = LinkNo
!Date = Now
!SpecNo = intSpecNo
!BrandNo = intSpecNo
!ParameterNo = intParameterNo
!ProcessNo = intProcessNo
!Code = Code
!ConcessionType = ConcessionType
!OOS = OOS
!OOC = OOC
!OOB = OOB
!Value = Value
If Len(CommentInput) > 0 Then !Reason = CommentInput
!ConcessionCode = ConcessionCode
!OriginatorNo = Forms!Logon!UserNo
!AnalysisNo = intAnalysisNo
.Update
.Close
I have no experience in Access or Access code to use a SQL db. Any help appreciated, ta.
Paul Watson Bluegrass Cape Town, South Africa
Roger Wright wrote:
Using a feather is kinky; using the whole chicken is perverted!
|
|
|
|
|
Yuk! I haven't done any development in Access for years, and you've just reminded me why!
Wouldn't it be easier to build a SQL UPDATE statement, and use the Execute method of the Database object to pass it through to the server?
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Richard Deeming wrote:
Wouldn't it be easier to build a SQL UPDATE statement, and use the Execute method of the Database object to pass it through to the server?
Thanks for the suggestion. That was basically our recommendation too. Seems as though the clients developer was using ODBC and coupled with those horrid DynaSet things was locking the row on just a simple view. Then when he wanted to update, the low was still locked and it refused.
Access front end to SQL back end is scary IMO, not a good idea.
Paul Watson Bluegrass Cape Town, South Africa
Roger Wright wrote:
Using a feather is kinky; using the whole chicken is perverted!
|
|
|
|
|
After doing some reading, I'm not exactly sure how to do this. Basically, I have a login screen with username and password textboxes. The user enters their information, then clicks Login. In the login button's click event I want to search an Access database table to see if the user is found, and if so, proceed to the main screen.
Could someone point me in the right direction, or post a link to a code sample? It would be greatly appreciated!
|
|
|
|
|
ADO or ADO.NET?
Just execute a "SELECT MyUsernames FROM MyTableWithUsernames WHERE MyUsernames='theusename' "
Execute with the ExecuteScalar function and see if the return value is 1, then 'theusername ' is found in the database.
I hope I'm right... if not.... leppie will kick my ass and tech me a lesson!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Which is the easiest way to get the number of records in a table?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
SELECT COUNT(*) AS [Count]
FROM Table
Who is this miscrosoft, and what devilish plans have they for us?
|
|
|
|
|
Thaaank you so much!
5p!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
leppie wrote:
AS [Count]
Hey leppie!
I need more help about what you said... I wrote my SQL query like this:
SELECT COUNT(*) AS NumberOfRecords FROM Login
But how do I get the field value (NumberOfRecords)!?!?!?!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
public static int GetRecordsInTable(string table, SqlConnection con)
{
SqlCommand cmd = new SqlCommand(
String.Format("SELECT COUNT(*) AS X FROM [{0}]", table), con);
con.Open();
object r = cmd.ExecuteScalar();
con.Close();
return (int) r;
}
Who is this miscrosoft, and what devilish plans have they for us?
|
|
|
|
|
leppie wrote:
String.Format("SELECT COUNT(*) AS X FROM [{0}]", table), con);
Dooh!
Tackar så mycket!
(thank you! )
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
SELECT TOP 10 *
FROM Table
ORDER BY ID DESC
Or a timestamp...
Who is this miscrosoft, and what devilish plans have they for us?
|
|
|
|
|
Is there any EASY way to write out to a debug lob from a SQL 2000 sproc?
I am seeeing all kinds of kludgy looking things like BCP isql\osql, xp_cmdshell.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
|
|
|
|
|
Hi!
I'm trying to display the statistics for my site; at each visit I add a record to a table (Accessi ) which contains two fields, one is a DATETIME with the current time (Data ) and the other is a VARCHAR(15) containing the ip address (ip ).
I want to display the total visit count for a certain month.
I created this query, that seems to work correctly, but is really slow!
(it runs against ~60000 records, but since I select a month at a time it shouldn't be SO slow, and since I'm porting this query from access, at least it shouldn't take more time than it used to do before...)
SELECT DATE_FORMAT(Accessi.Data, '%Y/%m/%d') AS Giorno, Count(DATE_FORMAT(Accessi.Data, '%Y/%m/%d')) AS Accessi
FROM Accessi
GROUP BY Giorno
HAVING Giorno BETWEEN '2002/12/1' AND '2002/12/31'
Can anyone help me in improving this query?
Luca Leonardo Scorcia
http://zip.to/kojak (only in Italian)
|
|
|
|
|
Two initial things to check:
1. Do you have a clustered index / primary key on the DATETIME column?
2. Do you have an index on the IP address?
Also, make sure you're not avoiding the index by using a function on the column - try converting the between clause to use dates.
Lastly, try group only what you want by using a where clause, so:
SELECT DATE_FORMAT(Accessi.Data, '%Y/%m/%d') AS Giorno, Count(DATE_FORMAT(Accessi.Data, '%Y/%m/%d')) AS Accessi
FROM Accessi
WHERE Giorno BETWEEN convert(datetime,'2002/12/1') AND convert(datetime,'2002/12/31')
GROUP BY Giorno
Please let me know if this helps.
|
|
|
|
|
Well, I was using mySQL, not SQL Server, so the convert function is not available to me... but I figured out how to solve it.
SELECT DayOfYear(Accessi.Data) as numGiorno, Accessi.Data, Count(Accessi.Data) AS Accessi
FROM Accessi GROUP BY numGiorno
HAVING numGiorno BETWEEN DayOfYear('2002/12/1') AND DayOfYear('2002/12/31') AND Year(Accessi.Data) = 2002
Thanks for your effort anyway! Bye!
Luca Leonardo Scorcia
http://zip.to/kojak (only in Italian)
|
|
|
|
|
Environemnt: VC++6,Access DB via ODBC.
How would one determine if a table exists in the database.
I have tried "SELECT * FROM TABLE_NAME"
where TABLE_NAME is the table I want to check for existence.
Thinking I would get an error or invalid return, Yet the the error gets trap and an caught before I can get to it or test for a return condition?
There has to be an easy way to check for table existance. RIGHT?
Thanks for any help
--Errol
|
|
|
|
|
Try this:
IF EXISTS (SELECT name FROM sysobjecs WHERE id = object_id(N'tablename')
AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
SELECT * FROM tablename
Or to get a list of tables (using this query in the EXISTS clause above also works), this is even easier:
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
"Well, I wouldn't say I've been missing it, Bob." - Peter Gibbons
|
|
|
|
|
I have a remote MySQL database and I'm trying to connect to it via MFC. I've tried using CDatabase but whatever I try, it never connects. I'm really new at this. Any help is appreciated.
Thanks in advanced,
Steve
|
|
|
|