|
It could be that your connection times out before it can connect to the SQL Server. Try a larger setting.
|
|
|
|
|
How to set timeout for SQL server check access rights ?
SQL server on remote computer either
connects very fast if succeeded,
but if user has no access right connects 10-30 seconds
and makes imression that application is hanged.
So question is:
how to decrease access rights time of check ?
Mostly needed to requrement to program it fast.
How such a problem is usually resolved in else ways ?
Asyncro connection works bad due to driver
not releases Connection.open() request fully,
but sends messages after it,
during that peiod application hangs.
Does that need full multi - threading programing?
Thanks.
|
|
|
|
|
Believe that one of the properties of the connection string is "ConnectionTimeout"
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
I tried to set all connection properties
wit word "Timeout"
but for checking rights it os not works.
|
|
|
|
|
|
For check rights it is not working.
|
|
|
|
|
Can you clarify what you mean by access rights. When forming a connection string, you can specify a UserID / Password combination, if you set the connection timeout to a small value and then attempt to connect using a specified user account, then if the login is not found straight away (as seems to be the case from your original post), then the timeout will kick in and the connection attempt will be refused...
Can you give me a little more info please?
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
When I connect to SQL server to which I has permission.
than I wait 20-30 secondes,
instead of 2-3 suffitient.
connection timeout not affects on this.
|
|
|
|
|
Hi,
I need to know the table structure of an MS-Access database. I tried Desc table sql and it doesnt seem to work. Is there any other method to know the structure of a table. I need to know it from VB/VC code and populate the result to a recordset.
Thanks for any help
Vikram Attiganal
|
|
|
|
|
Using ADO, you can call the Connection.OpenSchema method with the adSchemaTables flag. This returns a recordset with all the tables in. You can then iterate through this and call OpenSchema with asSchemaColumns and a table name specified.
Alternatively, you could use ADOX - this exposes a Catalog object, which if you give it an active connection object, holds an object model of the general structure
Catalog+
|
+
Tables+
|
+
Table+
|
+
Columns+
|
+
Column
To use ADOX, set a reference to ADO Ext. For DDL and Security
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
I have a vb.net script which inserts a new record into a sqlserver database.
I have ListID as the primary key (autonumber). I need to find a way of returning this number once I have saved the first part of the record, as on the next page I save some other fields of the same record.
Does anyone have any ideas?
*wasn't sure whether to post to here or to VB.net so sorry if on the wrong board*
Cheers, V
|
|
|
|
|
Hi there. You can use a select command with commandText "Select @@Identity" to get the inserted key from SqlServer. Here's a link[^] to a discussion forum thread that shows an example of this in context.
|
|
|
|
|
Thank you very much,
I have it returning the value now.
Cheers, V
|
|
|
|
|
Hi all,
I have a table with one column set as primary key, which
is not supposed to be duplicated. This key has a corresponding textbox on the form which the user enters manually.
I use .ExecuteNonQuery() after setting up the parameters of a SQLCommand object to insert a row. The SP does a simple insert routine.
Using one single button for updating the table (new row/existing row), is there a simple / automatic method to modify an existing row in the table (using Triggers, etc.) ? Or, do I have to write the code in the button that will -
first, fire an sp that returns back a boolean indicating whether a row with the user-entered primary key already exists, then
second, conditionally set the .commandtext value to either of the two SPs (INSERTSP / UPDATESP) depending on whether the boolean was row-exists/does-not-exist.
finally, fire the .executenonquery() ?
Any help will be highly appreciated.
Thanks in advance,
Sanjay.
|
|
|
|
|
How about this?
Instead of having two procedures for a simple task, have a single procedure which will check if the record is existing. If exists, update else insert. And finally this procedure can return you a status if you want to know if the record is inserted or udpated.
Bhaskara
|
|
|
|
|
Thanks, Bhaskara !
Regards,
Sanjay.
|
|
|
|
|
How can I check whether the data I would like to enter exist in the table or not.
For example, the primary key I would like to enter is 123. How do I check if this primary key already exist?
Please kindly guide me.
Thank you very much in advance.
|
|
|
|
|
bkpetluru wrote:
How about this?
Instead of having two procedures for a simple task, have a single procedure which will check if the record is existing. If exists, update else insert. And finally this procedure can return you a status if you want to know if the record is inserted or udpated.
Bhaskara
How can I check whether the data I would like to enter exist in the table or not.
For example, the primary key I would like to enter is 123. How do I check if this primary key already exist?
Please kindly guide me.
Thank you very much in advance.
|
|
|
|
|
see if you can autogenerate your primary key, instead of allowing to enter it manually. This would make sure that the data you are gonna insert would not be duplicate.
to answer your query,
one way of checking if primary key already exists is to use select count(*) query.
Bhaskara
|
|
|
|
|
From a design point of view, it is generally a bad idea to use data which has business meaning to a primary key. This is because data that has meaning has a nasty habit of changing - and changing primary keys can be a messy procedure.
That aside, you would face the same situation if you had a unique index on the column, so I will try and answer your question...
I have found that for problems that have a low likelihood of occurring (such as inserting duplicate data), it is simply best to try and do it, and then handle any resulting error. This is because you're going to have to handle errors anyway, and it does not make sense to spend a lot of time programming around it.
So, I would have a single SP that does the insert, and if the insert returns an error indicating a uniqueness constraint, then I would handle that in a user-friendly manner.
|
|
|
|
|
Hello Steve,
You are right there about using business-sensitive data as primary key. However, in my app, this primary key is a transaction number (for every voucher), that once fed in, can only be cancelled, and the rest of the fields modified - I am not allowing any change in the value of the transaction number _itself_.
Since I wanted the user to be able to make changes to the other contents of the voucher (such as date, amount transacted, accounts to be affected, etc.), I provided a single button - for fetching the transaction if the number entered by him exists in the database, or providing a blank fieldset - and another button that does the Posting of the transaction in the database (besides other buttons for delete/exit, etc.)
The code in that button had to take a decision on whether the transaction already existed or not, and then call INSERT or UPDATE. And since .net already seems to be doing a lot of hardwork internally, i was wondering if it was also providing a simple method/event that one had to perhaps, ping, in order to get to this information !
Regards,
Sanjay.
|
|
|
|
|
Hi,
I'm building an Application using C# and ADO.NET. As for now, I'd simply like to open a SqlConnection but the Compiler complains about multiple definitions of SqlConnection...
Here the error:
core\DBConnection.cs(49,4): warning CS1595: 'System.Data.SqlClient.SqlConnection' is defined in multiple places; using definition from 'c:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.Data.dll'
Any ideas?
Matthias
If eell I ,nust draw to your atenttion to het fakt that I can splel perfrectly well - i;ts my typeying that sukcs.
(Lounge/David Wulff)
www.emvoid.de
|
|
|
|
|
With the following SQL an exception is thrown in .NET which is entirely expected. However I'm not sure why the number is not set to the number in my RAISERROR
["..." have been included for brevity]
INSERT topic(topic_name...)
VALUES(@topic_name...)
SELECT @last_error = @@error
IF @last_error <> 0
BEGIN
ROLLBACK TRANSACTION
IF @last_error = 2627
BEGIN
RAISERROR(50300, 16, 1, @topic_name) WITH SETERROR
RETURN
END
END
With a certain error I want to report out of this stored procedure my own error and I want to be able to pick this up in my C# application with
catch(SqlException SqlEx)
{
if (SqlEx.Number == 50300)
{
}
}
If my RAISERROR is not the result of a previous error then everything is fine, the number I put in RAISERROR gets through to my SqlException.
Does anyone have any ideas of how to get this to work the way I want?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|
|
My understanding of SQL errors is that they stack up, in a collection. At least that was the way it was when I last worked with SQL errors, (in plain old ADO).
A quick glance at the docs tells me it is the same in .NET - take a look at the docs for the About SQLException class ...there is an Errors collection.
|
|
|
|
|
Steven Campbell wrote:
A quick glance at the docs tells me it is the same in .NET - take a look at the docs for the About SQLException class...there is an Errors collection
I can't believe I missed SqlException.Errors[^]
Thanks.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
My Blog
|
|
|
|