|
hello,
am working in c# an dtrying to connect to a sql server database.
my where clause is not working. without whre it's fine.
exception is :
the text,ntext and image data types can't be compared or sorted , except when using IS NULL OR LIKE operators.
now how can i use where clause.
e.g. plz
ASIM
Asim
|
|
|
|
|
I think the error message is self-explanitory.
onwards and upwards...
|
|
|
|
|
I get this problem using an OleDBConnection and executing a source code that inserts and deletes on multiple tables under same transaction (connection.BeginTransaction()). The problem decreases if I remove transactions management but the only crucial work around, for the moment, is closing and opening the connection before any insert, which is not acceptable solution.
Thanks,
Luigi
|
|
|
|
|
I am having trouble with the layout of the database to store source code.
I need someone to explain to me how to build the db so that I can create
categories and sub categories in a treeview. I am going to add the nodes
at runtime from a nodes table. The biggest thing is how to have multiple
nesting levels. Or if the subcategory has some code and more subcategories.
I know this dont begin to be all the info needed but it will give me a start.
Thank You
Bo Hunter
|
|
|
|
|
Run a search on google for 'celko tree' and see the large amount of information on how to do just this.
It's not that hard, just takes some planning.
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."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
Here are some table layouts we use for a hierarchial "file system" that is browsed via a tree in a web browser:
create table ic_DocumentCategory
(
DocumentCategoryKey int NOT NULL IDENTITY,
CompanyKey int NOT NULL,
Description varchar(80) NOT NULL,
VisibleToInternalUsers bit NOT NULL,
VisibleToExternalUsers bit NOT NULL
)
GO
create unique clustered index ic_DocumentCategoryDesc_idx
on ic_DocumentCategory (CompanyKey, Description)
create unique index ic_DocumentCategory_idx on ic_DocumentCategory (DocumentCategoryKey)
GO
create table ic_DocumentFolder
(
DocumentFolderKey int NOT NULL IDENTITY,
DocumentCategoryKey int NOT NULL,
ParentFolderKey int NULL,
Description varchar(80) NOT NULL,
OwnerInternalUserKey int NULL,
VisibleToInternalUsers bit NOT NULL,
VisibleToExternalUsers bit NOT NULL
)
GO
create unique clustered index ic_DocumentFolderCatParentDesc_idx
on ic_DocumentFolder (DocumentCategoryKey, ParentFolderKey, Description)
create unique index ic_DocumentFolderKeyDesc_idx
on ic_DocumentFolder (DocumentFolderKey, Description)
create unique index ic_DocumentFolderParentDesc_idx
on ic_DocumentFolder (ParentFolderKey, Description, DocumentCategoryKey)
GO
create table ic_DocumentFolderAccess
(
DocumentFolderAccessKey int NOT NULL IDENTITY,
DocumentFolderKey int NOT NULL,
CompanyKey int NULL,
CompanyUserKey int NULL,
RoleKey int NULL
)
GO
create unique clustered index ic_DocumentFolderAccessFolder_idx
on ic_DocumentFolderAccess (DocumentFolderKey, DocumentFolderAccessKey)
create unique index ic_DocumentFolderAccess_idx
on ic_DocumentFolderAccess (DocumentFolderAccessKey)
GO
create table ic_DocumentFolderFile
(
DocumentFolderKey int NOT NULL,
AttachmentKey int NOT NULL,
CompanyUserKey int NOT NULL
)
GO
create unique clustered index ic_DocumentFolderFile_idx
on ic_DocumentFolderFile (AttachmentKey, DocumentFolderKey, CompanyUserKey)
create unique index ic_DocumentFolderFileFolderAttach_idx
on ic_DocumentFolderFile (DocumentFolderKey, AttachmentKey, CompanyUserKey)
create unique index ic_DocumentFolderFileUserFolderFile_idx
on ic_DocumentFolderFile (CompanyUserKey, AttachmentKey, DocumentFolderKey)
GO
This syntax is for MS SQL7 or higher. Hope it gives you some ideas...
onwards and upwards...
|
|
|
|
|
I have error :
Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.
If you've got a solution to my problem, please help me !
|
|
|
|
|
Hi!
I'm currently developping an application that can communicate with Oracle, MySql or SqlServer Dbs thanks to ODBC.
It seems that the connection to these servers is slower on Windows 2000 server than on other Windows versions. (5 or 6 times slower)
Maybe it's because of a service or a network security option I should disable.
Please help me if you've got some ideas about my trouble.
jpeg
|
|
|
|
|
Is your connection configured to use TCP/IP or named pipes? TCP/IP is faster. Also, check that you are connecting using SQL Server authentication, rather than NT Authentication.
onwards and upwards...
|
|
|
|
|
Thank you for your answer but I already use TCP/IP and SQL Server authentification.
The power and memory of machines (2000 Pro and 2000 srv) are similar and they work on the same domain than the ODBC client ... I don't understand what is the problem.
I will keep on looking for one solution. Thanks.
jpeg
|
|
|
|
|
We ran into this when W2K first came out... but I don't remember what the solution was... sorry.
onwards and upwards...
|
|
|
|
|
I have a my program that writes data to an SQL database. It uses a loop to write in the data each time. But if I try to exit it Or the screen saver comes on, my program crashes and a NOT RESPONDING message comes up.
How do I fix this as I need to be able to exit my program if required..
Thanks.
grahamoj.
|
|
|
|
|
grahamoj wrote:
How do I fix this as I need to be able to exit my program if required..
Post some code please.
-Nick Parker
|
|
|
|
|
Hiya the code here is called each time to write the strings into the db. A file is read in each time it finds the right into to load, it calls this function:
int CPxhsinvDlg::LoadSQLDB(char* Invoice, char* LoadString)
{
int SQLStringSize=0;
int SQLStringSize1=0;
int SQLStringSize2=0;
CString sqlcmd;
try
{
// get the size of the string
SQLStringSize = strlen( LoadString );
// if the string is >= 7950
if( SQLStringSize >= MAX_LINE_SIZE )
{
char Line1[MAX_LINE_SIZE];
char Line2[MAX_LINE_SIZE];
// copy strings to new strings
strncpy( Line1,LoadString,MAX_LINE_SIZE );
strncpy( Line2,LoadString + MAX_LINE_SIZE,MAX_LINE_SIZE );
// get the size of string 1
SQLStringSize1 = strlen( Line1 );
SQLStringSize2 = strlen( Line2 );
// format the sql string
sqlcmd.Format("INSERT INTO PXHSINV (Invoice,Invoice_Code)"
"VALUES('Pt 1%s','Pt1 %*.*s')",
Invoice,
SQLStringSize1,
SQLStringSize1,
Line1);
// execute the sql string
pConnection->Execute(_bstr_t(sqlcmd), RecordsAffected, 1);
// empty string
sqlcmd.Empty();
// format the sql string
sqlcmd.Format("INSERT INTO PXHSINV (Invoice,Invoice_Code)"
"VALUES('Pt2 %s','Pt2 %*.*s')",
Invoice,
SQLStringSize2,
SQLStringSize2,
Line2);
// execute the sql string
pConnection->Execute(_bstr_t(sqlcmd), RecordsAffected, 1);
// empty string
sqlcmd.Empty();
}
else
{
// format the sql string
sqlcmd.Format("INSERT INTO PXHSINV (Invoice,Invoice_Code)"
"VALUES('%s','%*.*s')",
Invoice,
SQLStringSize,
SQLStringSize,
LoadString);
// execute the sql string
pConnection->Execute(_bstr_t(sqlcmd), RecordsAffected, 1);
// empty string
sqlcmd.Empty();
}
}
catch(_com_error &e)
{
_bstr_t bstrSource(e.Source());
_bstr_t bs = _bstr_t(" Error: ") + _bstr_t(e.Error()) + _bstr_t(" Msg: ")
+ _bstr_t(e.ErrorMessage()) + _bstr_t(" Description: ")
+ _bstr_t(e.Description());
MessageBox(bs,bstrSource, MB_OK);
}
return 0;
}
Is the problem of the program crashing on a screen saver common?? As I say it only crashes when I try to exit the during the loop or the screen saver kicks in.
How can I fix this??
Thanks.
|
|
|
|
|
Hello
I have a class that holds some interesing Data. Now i serialize this class (BinaryFormater) and i store this Class into a "IMAGE" Column of a SQL Table.
After that i retrieve the Column from the Table and deserialize it, so i can get my Data-holding Class back.
Thats the theory.
Does anybody know how to do this correct ?
Does anybody have some samples ?
mfG. Daniel Kirstenpfad
|
|
|
|
|
I'm doing some database in C# using MS SQL.
Problem #1:
Everytime i do a connection to my database, i have to copy and paste the code over and over. I heard of a way to put these code in the configuration file, but i don't know how to.
Problem #2:
I also heard of someway(interface, object) allowing me to do SQL query indirectly instead of passing the query string directly into the SqlCommand object. And, again, I don't know how to.
Problem #3:
Is there anyway i can pass in my sql query dynamically(ie, as a varible)?
I just learn C# on my own, and having problem searching for things like this
Please help me out!
THANKS A BUNCH!!!
|
|
|
|
|
puppiesLover wrote:
Problem #1:
Everytime i do a connection to my database, i have to copy and paste the code over and over. I heard of a way to put these code in the configuration file, but i don't know how to.
Depends on the type of database connector you're using, I guess. If you drop an SQL data connection onto a form, the IDE will automatically generate the code for it. If the generated connection string is not what is needed, I'll put code in the constructor to overwrite it. Be sure to place this code after the InitialComponents method call.
>>>-----> MikeO
|
|
|
|
|
I'm at a loss at how to add an allowed host to MySQL so I can at least connect to it. I am running the server on FreeBSD 4.8 and want to access it through my Windows box. Can anyone help me?
Matt Newman
Post best viewed with lynx
|
|
|
|
|
|
Is there a way to write a schema (like the *.xsd's created in the IDE) to the database? I'm trying to find a way to keep a schema in one place and after creating a new db (see previous post) write that schema into the db. I do realize that one can use the methods supplied to perform this piecemeal (table.Add(), row.Add(), etc...). I am looking for a tool - or better still - a method supplied by the framework (that I've just ben missing) to blast the xsd into the db.
α.γεεκ Fortune passes everywhere. Duke Leto Atreides
|
|
|
|
|
Is there a way (a la DAO's CreateDatabase() ) to create a new Access/Jet/OLEDB database in ADO.net? I've looked all over and just cannot locate the function anywhere. It seems from my reading that that scenario was not considered by the architects of the library. And, yes, I know I can add a reference to DAO and go that route - but was wanting to stick to all ADO.net.
α.γεεκ Fortune passes everywhere. Duke Leto Atreides
|
|
|
|
|
You can do it with ADOX. (requires COM Interop)
|
|
|
|
|
We use transactions in many of our stored procedures, and it seems I've either been lulled into a false sense of security, or am implementing them incorrectly.
We have an sp, called from an ASP page. It, briefly, does the following:
Select from table1 into a cursor
Begin Transaction
Insert into table2
exec sp_2
exec sp_3
Insert into table3
Delete from table1 (data collected and now inserted into the new tables)
IF @@error = 0
COMMIT TRANSACTION
ELSE
ROLLBACK TRANSACTION
I was under the impression this meant that either everything in the transaction would occur, or nothing. It's critical (for our data) that it works this way. However, when setting up a new server over the last couple of days I carelessly forgot to put permissions on a couple of the tables (it's a staging server, not a live one). This resulted in the delete (final item in the transaction) occuring, but none of the inserts occurred. Very worrying. Surely an error should have been generated when the inserts weren't allowed, and everything, including the delete, should have been rolled back?
As I say, it's not a problem, all nicely fixed once I realised the error of my ways. But I am curious about this. Is there perhaps something I am overlooking in my transactions? Or an option which should be set on SQL Server 2000 to keep transactions behaving the way I want them to?
Thanks for any info
To honor you, and your sick games, this smiley will now represent licking chocolate off candy - David Chamberlain
|
|
|
|
|
You need to check the error status after each operation!
BEGIN TRAN T1
Insert into table2
if @@error != 0
BEGIN
ROLLBACK TRAN T1
raiserror 50000 'Insert into table2 failed'
return
END
exec sp_2
if @@error != 0
BEGIN
ROLLBACK TRAN T1
raiserror 50000 'exec of sp2 failed'
return
END
exec sp_3
if @@error != 0
BEGIN
ROLLBACK TRAN T1
raiserror 50000 'exec of sp3 failed'
return
END
Insert into table3
if @@error != 0
BEGIN
ROLLBACK TRAN T1
raiserror 50000 'Insert into table3 failed'
return
END
Delete from table1 (data collected and now inserted into the new tables)
if @@error != 0
BEGIN
ROLLBACK TRAN T1
raiserror 50000 'Delete from table1 failed'
return
END
COMMIT TRANSACTION
onwards and upwards...
|
|
|
|
|
Thanks
To honor you, and your sick games, this smiley will now represent licking chocolate off candy - David Chamberlain
|
|
|
|
|