|
Anyone know of a way to connect to a btrieve 6.15 database using VB?
|
|
|
|
|
|
Hi.
I need to synchronize the local tables of my Access application with the tables that are deployed on the Web Server. My question is: Is this possible in MS Access or Do I need to use a different language to accomplish this synchronization module? Thank you very much for your insights...
|
|
|
|
|
i want to write a win32 DLL which can access SQL2000 database.
is there any win32 function existing?
Or i have to use MFC/.NET functions ?
|
|
|
|
|
Both ADO and ODBC can be used from a Win32 dll. Plus there is the SqlLib that comes with the SQL Server developer tools.
Have a read on MSDN for full details.
Michael
CP Blog [^]
|
|
|
|
|
I want another efficient way to re-write this query.
Note : @empid , @batchid and @name are not always passed to the SP
CREATE PROCEDURE FindEmployee
@empid INTEGER = NULL,
@batchid INTEGER = NULL,
@name VARCHAR(30) = '%'
AS
SELECT * FROM Employees
WHERE @empid LIKE COALESCE(CONVERT(varchar(3), @empid), '%')
AND @batchid LIKE COALESCE(CONVERT(varchar(3), @batchid), '%')
AND name LIKE ('%' + @name + '%'
1. If @empid and @batchid were not provided, is there a way to remove thoese columns from the where clause conditionally without writing a seperate query
2. What are the otherways to improve the performance of this kind of a query
Thanks
UB
You may stop this individual, but you can't stop us all... after all, we're all alike. +++Mentor+++
|
|
|
|
|
As a general rule, don't use functions or the LIKE operator on your table columns or your query won't use any indexes.
The easiest way of speeding this query is by replacing this (I assume there's a typo and there is no '@' outside the COALESCE):
WHERE empid LIKE COALESCE(CONVERT(varchar(3), @empid), '%')
AND batchid LIKE COALESCE(CONVERT(varchar(3), @batchid), '%')
for something like this:
WHERE empid BETWEEN @firstEmpid AND @lastEmpid
AND batchid BETWEEN @firstBatchid AND @lastBatchid
And do a bit of math to calculate the first and last ids.
If this filter returns a small result set, then the slowest part (show below) of the query won't need to run against a lot of records and the query will be way faster.
AND name LIKE ('%' + @name + '%'
Yes, even I am blogging now!
|
|
|
|
|
I create a new table. The table consists of only one column of type varchar(7) .
Now i want to fill 50 random values in this table. Each value should be a seven digit number. e.g the final shape of table should be something like:
Number
======
2216789
2134567
1287905
..
..
Can anyone tell me the SQL query to generate random numbers of seven digits and enter in a table ?? It is better if numbers entered are unique.
Imtiaz
|
|
|
|
|
Try:
select cast(rand() * 10000000 as integer)
my blog
|
|
|
|
|
Assuming we're talking about SQL Server, this will work for a single random number, but not for generating 50 random numbers simultaneously.
From BOL:
"Repetitive invocations of RAND() in a single query will produce the same value."
If you tried a single insert statement to insert 50 numbers simultaneously, they'd all be the same number.
Try this:
DECLARE @Rand TABLE (Number int PRIMARY KEY)
WHILE (SELECT COUNT(*) FROM @Rand) < 50
BEGIN
INSERT INTO
@Rand
(
Number
)
SELECT
FLOOR(RAND() * 8999999) + 1000000
WHERE
NOT EXISTS (SELECT * FROM @Rand WHERE Number = FLOOR(RAND() * 8999999) + 1000000)
END
SELECT * FROM @Rand
You'll notice, however, that when you do the select at the end, even though the 50 numbers are indeed random, they'll still most likely be in numerical order. If you want them randomly ordered, you should add an identity column to the table variable, and make it the primary key.
Grim (aka Toby) MCDBA, MCSD, MCP+SB
SELECT * FROM user WHERE clue IS NOT NULL
GO
(0 row(s) affected)
|
|
|
|
|
Hi. I try to connect to a Microsoft SQL database using Ole Db - IRowSet interface. This works, but I can't bind it to a grid control (I use Microsoft Datagrid control).
I have:
IRowset* pRowset;
DDX_Control(pDX, IDC_DATAGRID1, m_grid);
........................................
I try to bind by
m_grid.SetRefDataSource((LPUNKNOWN)pRowset);
but it raises an exception : Type mismatch.
Well, I tried - I suppose . Could someone help me?
Gabi
|
|
|
|
|
Hello everyone,
I want to know how can I refresh a detail table that connects to a master table.
I have a relation between the tables, but I don't use datagrid for the master table (I have controls on the form (VB.NET) that represent the master table columns and datagrid that suppose to get the child rows of the detail table) but when I move the cursor's position, the detail datagrid won't seem to refresh itself.
How can I use the relation when I dont use datagrids..?
thank, Roy
|
|
|
|
|
Hi
You please make clear that you are usring Database Table or DataTable.
SenDIL
|
|
|
|
|
Hey,
I use database tables.
The database is MSAccess.
|
|
|
|
|
Hie...
Please recommend the site which related to Ms Access database.
I had enough of connection to Ms SQL Database.
I visit tons and tons of connection of SQL.
Is there any Access connection out there?
Hope to hear from you soon.
Thanks.
Regards,
Aaron
|
|
|
|
|
|
I'm in the process of writing a stored procedure that copies information from one database to another. One of the pre-copy checks at the start of the stored procedure is to make sure that the logged in user has the right to create the tables and copy the data in the destination database.
How can I tell if the logged in user can access another database?
Also, I don't want it to raise an error while doing this. I currently have the following:
CREATE TABLE #temp (name sysname);
SET @stmt = 'USE ['+@destination_database+']; SELECT name from sysusers WHERE name='''+USER+'''';
INSERT #temp EXEC(@stmt);
My idea was to see if the #temp table contained any records, but obviously if the user has no permission to use the database this isn't going to work.
Any ideas?
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
From BOL:
"SCHEMATA
Contains one row for each database that has permissions for the current user. The INFORMATION_SCHEMA.SCHEMATA view is based on the sysdatabases, sysconfigures, and syscharsets system tables.
To retrieve information from these views, specify the fully qualified name of INFORMATION_SCHEMA view_name."
The following SQL query should give you a list of all databases on the server that the current user has permissions in. Use a WHERE clause and possibly a COUNT(*) aggregate if you just want to know if the user has access to one particular database.
SELECT CATALOG_NAME FROM INFORMATION_SCHEMA.SCHEMATA
Grim (aka Toby) MCDBA, MCSD, MCP+SB
SELECT * FROM user WHERE clue IS NOT NULL
GO
(0 row(s) affected)
|
|
|
|
|
That doesn't work. Actually I find that the INFORMATION_SCHEMA is quite eccentric in what it returns (see end note).
When I run the statement you gave, SELECT CATALOG_NAME FROM INFORMATION_SCHEMA.SCHEMATA , I get a list of all the databases. This is not useful as it still list the database that I cannot access.
If I SELECT * FROM INFORMATION_SCHEMA.SCHEMATA it tells me that the schema owner is the same as the user logged in for a database that that user cannot access.
If I then issue a USE [p1_p2_destination_database] command I get the following:
916: Server user 'fails_2' is not a valid user in database 'p1_p2_destination_database'.
'fails_2' is the user that is not supposed to be able to access that particular database (These are part of the tests I am running to ensure the stored procedure that I am writing behaves correctly for a given situation). All 'fails_2' has in the server is access in the 'master' and 'p1_p2_source_database', it also owns a table in 'p1_p2_source_database'. It is correct that it issues an error if I try to USE the 'p1_p2_destination_database' but I want to trap that situation before it arises.
I don't know if this helps explain the situation more clearly.
As an aside the code for INFORMATION_SCHEMATA is:
--Identifies schmata owned by current users, databases current users has permissions in
create view INFORMATION_SCHEMA.SCHEMATA
as
select
db.name as CATALOG_NAME
,USER_NAME() as SCHEMA_NAME
,USER_NAME() as SCHEMA_OWNER
,convert(sysname, NULL) as DEFAULT_CHARACTER_SET_CATALOG
,convert(sysname, NULL) as DEFAULT_CHARACTER_SET_SCHEMA
,a_cha.name as DEFAULT_CHARACTER_SET_NAME
FROM
master.dbo.sysdatabases db,
master.dbo.syscharsets a_cha --charset/1001, not sortorder.
WHERE
a_cha.type = 1001 --- type is charset
AND a_cha.id = convert(tinyint, DatabasePropertyEx(db.name, 'sqlcharset'))
I don't see anywhere in this where filters anything by permission. If anything just returneing USER_NAME() for the SCHEMA_NAME and SCHEMA_OWNER is just pointless.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
Hi,
I am writing an VC++ application which access SQL server/Oracle/MS-Access/excel etc using ODBC drivers.
I have some basic knowledge of ODBC API's like SQLOpen, SQLGetSchema etc but no clue of how to implement and get the data from the above mentioned databases into my VC++ application.
Can anybody help me out sending some links, code examples etc.
Thanks,
Prashant
|
|
|
|
|
I have an xml datastream and would like to know the syntax to map the contents to a specific excel worksheet and xml map. This is to automate 30+ complex reports in excel (must be excel - and no iis available to make my job much easier!). I anyone has a better solution I welcome it.
This is my syntax so far:
Dim objConn As ADODB.Connection
Dim objCMD As ADODB.Command
Dim objResultStream As ADODB.Stream
Dim xmpCustomMap As XmlMap
On Error GoTo Handle_Error
Set xmpCustomMap = ActiveWorkbook.XmlMaps("triangle_Map")
Set objConn = New ADODB.Connection
objConn.Open "Provider=SQLOLEDB;server=mydb;Database=Development;" & _
"Integrated Security=SSPI"
Set objCMD = New ADODB.Command
Set objCMD.ActiveConnection = objConn
't-SQL DIALECT
objCMD.Dialect = "{C8B522D7-5CF3-11CE-ADE5-00AA0044773D}"
objCMD.CommandText = "Exec dbo.proc_xml 1394"
objCMD.CommandType = adCmdText
Set objResultStream = New ADODB.Stream
objResultStream.Open
objCMD.Properties("Output stream") = objResultStream
objCMD.Properties("XML Root") = "Root"
objCMD.Execute , , adExecuteStream
Debug.Print objResultStream.ReadText(adReadAll)
|
|
|
|
|
I want to create a secure Access-Database from C#.
I want to create a Database and a Systemdatabase - I suppose this works only in the same time.
Why does the following code not work?
private void button1_Click(object sender, System.EventArgs e)<br />
{<br />
ADOX.Catalog catalog = new ADOX.Catalog();<br />
catalog.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\\new.mdb;Jet OLEDB:System Database=e:\\new.mdw;Jet OLEDB:Create System Database=true");<br />
}
- it creates the e:\new.mdb but fails to create the e:\new.mdw.
I use Visual Studio 2003 and I have tried this
- on WXP with installed Access2003 and
- on W2K with installed Access97 and Access2000
All with the same result.
|
|
|
|
|
I met a trouble to create a customized report against MS-Server OLAP in crystal report. The report what I want could not be described clearly here. If anyone of you is interested in it, I'd like to send you a sample of it by your email.
BTW, anyone knows how to attach a file on this board?
Thanks,
Yanh100
|
|
|
|
|
'Cause right now I'm getting this from compiler:
<br />
c:\...\msado15.tlh(26) : error C2371: 'Properties' : redefinition; different basic types<br />
c:\mvs\microsoft sdk\include\adoint.h(242) : see declaration of 'Properties'<br />
c:\...\msado15.tlh(28) : error C2371: 'Property' : redefinition; different basic types<br />
c:\mvs\microsoft sdk\include\adoint.h(238) : see declaration of 'Property'<br />
c:\...\msado15.tlh(30) : error C2371: 'Error' : redefinition; different basic types<br />
c:\mvs\microsoft sdk\include\adoint.h(66) : see declaration of 'Error'<br />
c:\...\msado15.tlh(32) : error C2371: 'Errors' : redefinition; different basic types<br />
c:\mvs\microsoft sdk\include\adoint.h(70) : see declaration of 'Errors'<br />
c:\...\msado15.tlh(36) : error C2371: '_Connection' : redefinition; different basic types<br />
c:\mvs\microsoft sdk\include\adoint.h(106) : see declaration of '_Connection'<br />
... and so on for everything there is in msado15.tlh.
Help!
Thanks in advance!
|
|
|
|
|
Im currently writing a program that uses ADO to connect to a database. When the program is compiled in release mode then, run it, the connection is OK. But when I try to use the exe file of the program alone, the connection failed. what seems to be the reason?
pls help!
tnx in advance!
|
|
|
|