|
Oh.. sorry . already answered! .. net is too slow
D!shan
|
|
|
|
|
I've been reading the former Wrox book "Professional ADO.NET Programming", and the samples in Chapter 3 requies an SQL database named "WroxDB", the downloaded source code includes a SQL script file named "WroxDB.sql". I'm new in SQL scripts, and stored procedures. I have VS.NET and MSDE installed, I tried running this script from osql using this:
C:\MSSQL7\Binn>osql -U sa -P -i C:\WroxDB.sql
The WroxDB.sql file contains this:
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tabAuthors]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[tabAuthors]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tabPayments]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[tabPayments]
GO
CREATE TABLE [dbo].[tabAuthors] (
[AuthorID] [int] NOT NULL ,
[Author_FirstName] [char] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[Author_LastName] [char] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[Photo] [image] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[tabPayments] (
[PaymentID] [int] IDENTITY (1, 1) NOT NULL ,
[AuthorID] [int] NOT NULL ,
[Payment] [money] NOT NULL ,
[Paid] [bit] NULL
) ON [PRIMARY]
GO
This execution always displays this message:
1> 2> 3> 1> 2> 3> 4> 1> 2> 3> 4> 5> 6> 7> 8> Msg 170, Level 15, State 1, Server
MANUELJR, Procedure , Line 4
[Microsoft][ODBC SQL Server Driver][SQL Server]Line 4: Incorrect syntax near
'COLLATE'.
1> 2> 3> 4> 5> 6> 7> 8> 1> 2>
C:\MSSQL7\Binn>
Please help, support in APRESS in this book is terrible.
|
|
|
|
|
(1)I would run this in SQL Query Analyzer instead of osql. By default, sa is going to create these structures in the Master DB. That is never a wise method of operating. You could add a few statements at the top to handle the database creation also.
CREATE DATABASE TestingDb
GO
USE TestingDb
GO
(2) The script ran fine on my box. You can always drop the COLLATE statement and just use your systems default collation for strings. Your error may have something to do with your SQL version or SQL installation choices.
CREATE TABLE [dbo].[tabAuthors] (
[AuthorID] [int] NOT NULL ,
[Author_FirstName] [char] (50) NOT NULL ,
[Author_LastName] [char] (50) NOT NULL ,
[Photo] [image] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
|
|
|
|
|
This is a SQL 2000 script that you are running on SQL 7. Not all of the SQL 2000 syntax is supported in SQL 7 -- specifically, it may run if you remove the COLLATE SQL_Latin1_General_CP1_CI_AS pieces. There may be other incompatibilities though.
my blog
|
|
|
|
|
OK, I've uninstalled SQL 7 and installed MSDE SP3a. I'll try your suggestions when I get home. One problem is, I've deleted all entries of MSSQL in the registry but when I try to run the SQL Server Service Manager, there's a blank entry above the MANUELJR entry in the Server combo box, is this right? What's that blank entry? Does that mean that I've missed or did not properly removed SQL 7? Please help.
|
|
|
|
|
Can you tell me what is windows you are using? (w2k, xp...) answer clearly about its version (if win2k tell me, server or pro.)
On the other hand, check on wrox website. They also have an errata site for user to post any question or any error on it to update to the correct one.
Roath Kanel
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
I'm using Windows XP Pro, almost all of old Wrox titles are in APRESS now, I've downloaded the sample files. There's no errata, even though I've found several errors in the book already. Forums on previous Wrox books in APRESS are not well organized, all questions regarding them are just in one forum topic, so it's very difficult to find out if anyone is having a question about my book.
|
|
|
|
|
I am desperately trying to make a connection to an MS Project 2000 (or 2003)in order to extract some well defined data and to make some work on them and to put the results in SQL Server 2000. However I can't find the connection string in order to connect to MS Project.
Lastly I found the following OleDbConnection object :
' ... OleDbConnection conData = new OleDbConnection("Provider=Microsoft.Project.OLEDB.11.0; PROJECT NAME=h:/Plan Projet POC-Review1.mpp"); ... '
However it doesn't work.
More. Before connecting to MS Project, has the .mpp file to be "saved as type: Project Database" in the "save as" box which produces an .mpd file, before trying to connect.
I know I could handle the problem through the use of a DTS package but for some reason I have to do it through the use of ADO.NET and C#.
Please could somebody help me before getting grey hair (I already got some)
and
Frank
|
|
|
|
|
I have some questions regarding SQL select command, but first let me explain my condition first.
I am a newbie in C# and SQL, and developing some window application with database connected from SQL Server.
And the questions I have is when the select command only want to retreive some portions of data (one or two rows from hundreds of row from the same table).
I know there are two type or methods of having the select command: stored procedure and non-stored procedure.
For the stored procedure, the query is processed in the SQL Server, and return the result to the workstation.
But for non-stored procedure select command, is it doing the same thing? or the query return all row of data to the workstation, and then the workstation process it after receive all the data?
Since I have concern that my network will be overloaded if all the data are being transfered only to take one or some rows of data.
Thank you very much in advance.
|
|
|
|
|
With an ad-hoc query (a query passed to the server, instead of using a stored proc) the SQL Server will still honor the where clause and only return the rows you want to the application.
There are a couple of advantages to stored procs over ad-hoc queries:
- ad-hoc queries have to be compiled every time you perform the query. Stored procedures are compiled, then the compiled version is re-used for some time, and re-evaluated/re-compiled only occasionally. This is a major benefit in high-volume systems.
- depending on the app, sometimes it's possible to tweak performance and/or operation of an application with modifications to the stored procedure, without having to recompile the entire application to implement the change.
- depending on the complexity of the query, sometimes it's simply easier to read the code when the SQL code is completely isolated from the C#/VB code, instead of the two being mixed together in the application.
There are more benefits to procs, of course. And there are some benefits that ad-hoc queries have over procedures (although IMHO few and far between.) But I much prefer using procs. Mainly for the reasons listed above.
Grim (aka Toby) MCDBA, MCSD, MCP+SB
SELECT * FROM user WHERE clue IS NOT NULL
GO
(0 row(s) affected)
|
|
|
|
|
ADO.NET (your SqlDataAdapter , etc) is a disconnected system. Meaning, all the data is held and manipulate on the client. (Someone correct me if I am wrong here...) So, no matter how you structure your query, all the data goes to the client when you call the Fill method on your SqlDataAdapter .
If you are concerned about swamping your connection, I suggest you write a more restrictive query, so that it only returns the rows you actually need. If you cannot tighten up the logic, you can try something like:
<br />
select top 2 column1,column2, etc<br />
from YourTable<br />
Hope this helps,
Bill
|
|
|
|
|
Thank you very much for the reply.
I guess from the reply, I understand it much more than before, and I think I am in the right path.
In most of my query, I used ADO.NET, but restricted the select command to the columns and rows that I am interested in by using WHERE clause.
My concern was, the network load of the select command.
I was afraid that the ADO.NET select command retreive all the data and rows even I only selected one column or row. And then the client applied filter to the retreived data to get the data I wanted.
But I guess I'm wrong.
Again, thank you so much for the reply. It gives me very much information and knowledge about SQL.
|
|
|
|
|
SqlServer does the "selecting" so only the results of the query travel from the server to your client application.
Bill
|
|
|
|
|
Yes, I understand it now.
Thank you very much for the reply.
|
|
|
|
|
Antonius_r3 wrote:
My concern was, the network load of the select command.
I was afraid that the ADO.NET select command retreive all the data and rows even I only selected one column or row. And then the client applied filter to the retreived data to get the data I wanted.
But I guess I'm wrong.
Just as a clarification: It is SQL Server that is lowering your network traffic not ADO.Net. If you sent the same query to a remote MSAccess MDB database (via ADO.Net) you would experience a much heavier network hit since the filtering would happen on the client.
|
|
|
|
|
Hi, I'm using ODBC to query a database that can be selected by the user at runtime. This query "SELECT * FROM MSysObjects WHERE Type = 1 AND NOT Name LIKE 'MSys%'" will return a list of table names fine, but unfortunately, persmissions on the ACCESS DB must be set to ADMIN for this query to succeed. Is there another way to get table names from a DB without having to first alter persmissions? or is there a programatic way to alter permissions?
Thanks.
"Ergo huffabo et puffabo et tuam domum inflabo" ait magnus malus lupus.
"Non per comam men-men-menti!" ait porcellus.
|
|
|
|
|
Hi, I seemed to have solved it using SQLTables() function....Thanks anyway.
"Ergo huffabo et puffabo et tuam domum inflabo" ait magnus malus lupus.
"Non per comam men-men-menti!" ait porcellus.
|
|
|
|
|
Getting now "Unable to load odbcji32.dll" message box.
Even in "Data Sources (ODBC)" can't configure MS Access DB anymore. What's up?
Thanks for ideas in advance!
|
|
|
|
|
currently I use the following pseudocode for updating
AddNew(...);
SetFieldValues(Field, Value);
Update(...);
Now I'm updating a LOT of data whereas it takes about 1 minute to finish an update of the database. Is this not untypical for database updates that affect 1000's of records or are their ways to optimize updates of this nature so the user isn't stuck waiting for so long?
thanks!
|
|
|
|
|
That is probably the slowest method of updating data. Other options are:
* Place all inserts inside a single transaction -- will give some speed improvement
* Use SQL insert commands instead, using a precompiled command with parameters. This is very efficient and my recommended choice.
* Use a bulk upload tool, such as BCP, or SQL DTS packages
.NET 2.0 will include better bulk data support, but until then you are stuck with the above options.
my blog
|
|
|
|
|
wot is the latest service pack or update for sql server 2000.
|
|
|
|
|
Check This[^] it might be the final one.
Roath Kanel
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
I'm wondering what others do when they are updating records in a database. In the application I have I am deleting all records and adding a fresh set. I do this simply because either 1 record to all records could be effected and to keep track of effected records means more code. However is it worth to code an object to keep track of changes or is it simply easier to erase and rebuild?
simply curious.
|
|
|
|
|
Well usually data is linked in some way to other data, and in that case it makes sense to go to the trouble of updating existing records.
If your data lives on its own, with no other data that links to it, then I see no problem with what you are doing.
my blog
|
|
|
|
|
How do I find the column (index) number at runtime of a particular DataGrid column if I know the column header string
//somthing like the following
int x = datagrid.column["ID"];
|
|
|
|