|
You are welcomed, please check the dest file by Access 2000. Make sure the new password is function.
JW
|
|
|
|
|
It already has that resolution (actually 100 nanosecond resolution), but if you are displaying it in a datagrid the default column format does not show it. try:
private static String timeFormat = "MM/dd/yy HH:mm:ss:fff";<br />
private static int timeColumnWidth = 120;<br />
<br />
DataGridTableStyle ts1 = new DataGridTableStyle();<br />
foreach (DataColumn dc in dataTable.Columns)<br />
if (dc.DataType == typeof(DateTime))<br />
{<br />
columnFmt.Format = timeFormat;<br />
columnFmt.Width = timeColumnWidth;<br />
}<br />
ts1.GridColumnStyles.Add(columnFmt);<br />
ts1.MappingName = dataTable.TableName;<br />
ts1.ColumnHeadersVisible = true;<br />
ts1.ReadOnly = true;<br />
dataGrid1.TableStyles.Clear();<br />
dataGrid1.TableStyles.Add(ts1);<br />
dataGrid1.DataSource = dataTable;<br />
<br />
If you are trying to save this to SQL server, it can only handle a resolution of 3 ms in the SqlDateTime fields, Other databases may share the same lack of resolution or worse with thier 'Native' date/time columns You might have to convert the DateTimes to a long integer (DateTime.Ticks) and save that, converting back when you read it
-- Always be sure to maintain adequate insulation between lap and Laptop
Rob
|
|
|
|
|
Thanks a lot for your guidance.
and how can I fill a datetime field in a table programmatically with millisecond resolution for example in C# syntax?
Thank you in dvance.
|
|
|
|
|
Hi,All
RecordCount Property giving me -1 value
Please read my code and give me where i am doing wrong;
and also please comment on my Code(if their any mistakes)
Thanks in Advance..
/////////////This is my code To Test the Function////////////////////
_RecordsetPtr pRst;
CString strTemp;
pRst.CreateInstance(__uuidof(Recordset));
pRst=GetData(1);
if(pRst!=NULL)
{
int nCount=(int)pRst->RecordCount;
strTemp.Format("%d",nCount);
AfxMessageBox(strTemp);
}
else
{
AfxMessageBox("Recordset null");
}
pRst.Close();
pRst.Release();
////////////////////////////////////
///////////////////This is my funtion which will return me Recordset object///////////
_RecordsetPtr GetData(int nType)
{
CString strType;
strType.Format("%d",nType);
try
{
//COM Library Initialization
if(FAILED(::CoInitialize(NULL)))
{
//Log error
return NULL;
}//if(FAILED(::CoInitialize(NULL))
//Open the Connection
m_hr=m_pConnection.CreateInstance(__uuidof(Connection));
if(FAILED(m_hr))
{
::CoUninitialize();
//Log error
return NULL;
}
m_strCnnString=GetConnectionString();//It will give me the Connection String
_bstr_t cnnString(m_strCnnString);
_bstr_t bstrEmpty("");
m_hr=m_pConnection->Open(cnnString,bstrEmpty,bstrEmpty,adConnectUnspecified);
if(FAILED(m_hr))
{
m_pConnection.Release();
::CoUninitialize();
//Log error
return NULL;
}
//Get the Command objet
m_hr=m_pCommand.CreateInstance(__uuidof(Command));
if(FAILED(m_hr))
{
m_pConnection->Close();
m_pConnection.Release();
::CoUninitialize();
//Log error
return NULL;
}
m_pCommand->ActiveConnection=m_pConnection;
m_pCommand->CommandText="Sp_GetData";
m_pCommand->CommandType=adCmdStoredProc;
//Append the Parameters to Command object
//Type Parameter
m_pParam=m_pCommand->CreateParameter(_bstr_t("Type"),adInteger,adParamInput,4,_variant_t(strType));
m_pCommand->Parameters->Append(m_pParam);
m_hr=m_pRecordSet.CreateInstance(__uuidof(Recordset));
if(FAILED(m_hr))
{
m_pConnection->Close();
m_pConnection.Release();
::CoUninitialize();
//Log error
return NULL;
}
//Execute the SP
m_pRecordSet->CursorType=adOpenStatic;
m_pRecordSet=m_pCommand->Execute(NULL,NULL,adCmdStoredProc);
return m_pRecordSet;
}//try block
catch(_com_error &comExcep)
{
//Handle the error
}
catch(CException * GenExcep)
{
//Handle the error
GenExcep->Delete();
}
//CleanUp the objects
if(m_pCommand!=NULL)
{
m_pCommand.Release();
}
if(m_pConnection!=NULL)
{
m_pConnection->Close();
m_pConnection.Release();
}
::CoUninitialize();
return NULL;
}
//////////////////This is my StoredProcedure /////////
CREATE PROCEDURE [dbo].[Sp_GetData]
(
@Type[int]
)
AS
Begin
SELECT
Data1,
Data2,
Data3
Data4,
Data5
FROM
tblTestData
WHERE
(Data1=@Type)
End
GO
/////////////////////////////////////////////
anju
|
|
|
|
|
anju wrote:
RecordCount Property giving me -1 value
MSDN has an article:
PRB: ADO: Recordcount May Return -1[^]
You might also review the example on this site:
Filter and RecordCount Properties Example (VC++)[^]. Here is a snip of what I am talking about.
rstPublishers->CursorType = adOpenStatic;
TESTHR( rstPublishers->Open("publishers",strCnn,
adOpenStatic , adLockReadOnly,adCmdTable));
intPublisherCount = rstPublishers->RecordCount;
Hope this helps.
Nick Parker
May your glass be ever full.
May the roof over your head be always strong.
And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing
|
|
|
|
|
Hi Nick,
Thanks for your reply,
Still now RecordCount Property giving me -1;
what your provided information is good if i am getting
the recordset through "adCmdText or adCmdTable"
but here i am getting the recordset through "adSotredProc".
r u observed this difference?
i am getting full recordset with out any problem except
RecordCount.
Actually my problem was concentrated here....
//Execute the SP
m_pRecordSet->CursorType=adOpenStatic;
m_pRecordSet=m_pCommand->Execute(NULL,NULL,adCmdStoredProc);
return m_pRecordSet;
---In the above code.Eventhogh i assigned "adOpenStatic" to CursorType it is not replicating it is defaultly taking the
"adOpenForwardOnly".
//////////
_RecordsetPtr pRst;
CString strTemp;
pRst.CreateInstance(__uuidof(Recordset));
pRst=GetData(1);
if(pRst!=NULL)
{
int nCount=(int)pRst->RecordCount;
strTemp.Format("%d",nCount);
AfxMessageBox(strTemp);
}
else
{
AfxMessageBox("Recordset null");
}
pRst.Close();
pRst.Release();
/////////////////////////
----Can u tell where i have to set the CursorType?
Once again i am waiting for your reply...
thanks in advance
anju
|
|
|
|
|
Hello,
I have an app that uses an Access DB. I want to repair and compact the database but I can't seem to close the DB properly. I'm using CCommand:
m_Command.m_session.Close();<br />
m_Command.Close();
but the .ldb file remains... how can I make sure the link to the DB is removed???
Thanks!
---------------
Tired of Spam? Introducing InboxShield® for Microsoft® Outlook®
http://www.edovia.com
|
|
|
|
|
I believe you need to close the session's datasource to close the connection, as well as the session.
R
|
|
|
|
|
And how do I do that?
Thanks!
---------------
Tired of Spam? Introducing InboxShield® for Microsoft® Outlook®
http://www.edovia.com
|
|
|
|
|
When you created the session object, you must have passed it a DataSource Connection (CDataSource) instance, which you opened with the connection string specifying the providor ,db name, and path to the database. It is this connection that must be closed (not just the session instance) CDatasource::Close. If you used the CDataConnection class to open the session, this unfortunately hides its contained CDataSource (doesn't appear to expose either it or its close method), and you will have to destroy (delete) the CDataConnection to force it to close the connection (Open new instances using the intialization string used for the original connection.
R
|
|
|
|
|
I would like to access the data to SQL server on a remote machine. Are there any issues when connecting via an IP address vs. writing my own server and marshalling the queries through it. I would prefer to connect directly so I have all the power of recordsets locally in my application.
Some of the issues I would like to know about are:
1) Security - Does the data come in a raw format with the schema and everything?
2) Performance - What kind of overhead does the transfer make?
3) Usability - Is it really as easy as connecting to SQL server on a local machine?
4) Anything else I should know
Cheers,
Clint
|
|
|
|
|
1. Unless you enable protocol encryption the data is transferred a a binary stream (TDS- Tabular Data Services) protocol for the marshalling - SQL proprietary format. The Schema will also be there if it would have been there on a local call.
2. Performance is better than marshalling datasets, but will depend on the speed and available bandwidth of the network connection.
3.Security is more of an issue, and will depend on how you set up SQL. Best is NT authentication(Trusted_connection=yes in connection string), but this requires that the client either be in the same NT domain, or that the user on the client have an account on the server with identical username and password and that account has necessay priveleges to talk to the db in question.
4. Use TCPIP net protocol for best performance (Network=dbmssocn in connection string). Design the application to minimize round trips to the server. Use connection pooling on the client. Use stored procedures werever possible.
Read the SQL dos & donts article All of the advice applies...
Good luck
Rob
Trust NoOne...
|
|
|
|
|
Does anybody know how to force the SQL Server OLEDB provider to output narrow characters instead of wide ones? I need to test a couple of things..
I imagine it's a matter of tweaking the connection string/properties, but I just can't find it in the MSDN (as usual ).
--
standing so tall, the ground behind
no trespassers, on every floor
a garden swing, and another door
she makes it clear, that everything is hers
A place of abode, not far from here, Ms. Van de Veer
|
|
|
|
|
Here is a resultset:
ID Name Value
---------------------------------
101 Name1 Value1
101 Name2 Value2
101 Name3 Value3
101 Name4 Value4
101 Name5 Value5
101 Name6 Value6
Could anyone tell me a way that could transform the above resultset in something like next one? (I'd prefer an SQL approach / not cursors and so on... but i appreciate them anyway).
Name1 Name2 Name3 Name4 Name5 Name6
----------------------------------------------
Value1 Value2 Value3 Value4 Value5 Value6
Is there any solution that don't use OLAP or extended procedures?
ThanX,
In MSAccess things are simple (see Crosstab query) - but in SQL Server 7 I don't know how to do it.
|
|
|
|
|
acosmin wrote:
Is there any solution that don't use OLAP or extended procedures?
Absolutely. Ok, for my 2 cents worth I think you need to look at what you are asking. An SQL statement is returning a recordset to you, you however just want to modify the display. While manytimes "modifying" the display of a recordset can be easily done within the SQL statement itself, manytimes this is not the route to follow. What I am getting to is if you iterate through the recordset and throw the values into an array structure you can easily display your output as you want (from the array) it without modifying the SQL statement at all. What language are working with? Does this help at all?
Nick Parker
May your glass be ever full.
May the roof over your head be always strong.
And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing
|
|
|
|
|
Here is a resultset:
ID Name Value
---------------------------------
101 Name1 Value1
101 Name2 Value2
101 Name3 Value3
101 Name4 Value4
101 Name5 Value5
101 Name6 Value6
could anyoane tell me a way that could transform the above resultset in something like next one? (I'd prefer an SQL approach / not cursors and so on... but i appreciate them anyway)
Name1 Name2 Name3 Name4 Name5 Name6
----------------------------------------------
Value1 Value2 Value3 Value4 Value5 Value6
ThanX,
In MSAccess things are simple but in SQL Server 7 I don't know how to do it.
|
|
|
|
|
Hi
How does one differenciate between say two Routines when querying the INFORMATION_SCHEMA ? It doesnt seem to return a column with that value...
Thanx
"I dont have a life, I have a program." Also, I won't support any software without the LeppieRules variable.
|
|
|
|
|
Greetings,
I recently created a table which has a datetime varible which stores the date and time such as this "11/18/2002 1:30:33 PM".
But now I want to have milliseconds stored in this as well, such as shown below.
"11/18/2002 1:30:33.33 PM".
By default it does not allow me to add the ".33", so I am assuming it is just a formating setting when I create my table, but I am not sure how to do this? Any suggestions on how to do this?
Here is a sample section of my code of how I create my table with the date, and how I do insertion of the data. I am using sql server 2000, and ADO via Visual C++ 6.
CREATE TABLE MyTestSql
(
MyTestDate datetime
}
INSERT INTO MyTestSql(MyTestDate)
VALUES('11/18/2002 1:30:33 PM')
Thanks in advance for help?
|
|
|
|
|
Greetings,
As usual if you work on something, right after you make the post you find the solution to your problem.
It seems that microsoft sql server rounds up the time value's millisecond, so that it doesn't show up in the database. It had nothing to do with formating the date and time.
Here is a link that explains a solution on how to get your milliseconds back.
http://support.microsoft.com/default.aspx?scid=KB;en-us;q186265
|
|
|
|
|
Hai all,
We have a sql server table (which contains a Guid col + others). For processing the data in this table (about 0.1 million records a day), we move the data to access db on the user's desktop.
Currently we are using ADO to access the sql server and update the local access db (using batch update). It takes about 10-15 minutes for the whole operation. Is there a faster way to do this ? We have a requirement to move records from SQL to access based on certain filter criteria .
Any pointers will be greatly appreciated
|
|
|
|
|
Have you looked at DTS? I'm not sure if it'll be any faster but I use it a lot to move data from one place to another.
Michael
Life’s not a song.
Life isn’t bliss.
Life is just this.
It’s living. -- Buffy the Vampire Slayer: Once more, with feeling
|
|
|
|
|
Ravish wrote:
Currently we are using ADO to access the sql server and update the local access db (using batch update). It takes about 10-15 minutes for the whole operation. Is there a faster way to do this ? We have a requirement to move records from SQL to access based on certain filter criteria .
As Michael suggest, use DTS. It will work (with filtering and all sorts of other options) but you won't have any fun. DTS is painful IMO.
Paul Watson Bluegrass Cape Town, South Africa Colin Davies wrote:
...can you imagine a John Simmons stalker !
|
|
|
|
|
I am trying to (re)write a knowledgebase, cuz it sux a$$.
Anyways...I have a keywords field in the database and the user enters keywords into an input field.
The code constructs a query which looks something like this:
SELECT * FROM kb_articles WHERE Keywords LIKE '%Show%' OR Keywords LIKE '%Me%' OR Keywords LIKE '%the%' OR Keywords LIKE '%money%'
I'm not a whiz at SQL so i'll explain myself here a little incase my syntax if off or something...
Obviously i'm selecting records from a table called kb_articles which has the following structure:
PKID | Question | Answer | Keywords |
Keywords and Answer should be searched for potential results. As far as I can tell, the above won't work (i'm using mySQL BTW) because LIKE chokes on multiple words.
Example?
Question entry page:
Question: How can I make lots of money?
Keywords: Show me the money
The script then parses Keywords and Questions into individual array elements (seems logical) and those items are what get compared to each record inside kb_articles keywords field. Only the keywords field can also have multiple keywords and these aren't parsed into indy words, so basically what's happeneing is this:
kb_articles.keywords = "How, To, Show, The, Make, Money"
SELECT * FROM kb_articles WHERE keywords LIKE '%Show%'....
LIKE i think chokes on multiple words inside the database keyword field...
So my question is this...Is there a way I can use SQL regex to compare I have no idea about anything REGEX... or am I going to have to execute multiple queries constructed using PHP...?
Thanks in advance
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Sorry ,I can't understand what say.
In the example that you say,what does the query return?
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
That SELECT statement looks like it should work but you will have to put more LIKEs in there if you want a better search. For example, you may want to use LIKE '%Show me the money%' or LIKE '%Show%me%the%money%' or LIKE '%show%me%' etc.
Jason Henderson start page ; articles
henderson is coming
henderson is an opponent's worst nightmare
* googlism *
|
|
|
|