|
Hi,
I would like to know the advantages of using ADO.NET in C# application development.
Thank You.
ranga
|
|
|
|
|
rangaSL wrote: I would like to know the advantages of using ADO.NET in C# application development.
It is most advantageous if you want to get data in or out of the database because it is the only way to do that.
|
|
|
|
|
Dear Mr.Colin,
Thank you very much for your reply.
RangaSL
|
|
|
|
|
Dear Ranga,
we cant talk about advantages of ADO.NET because either u use c# or VB or any language that is supported by .net framework the only way to connect to the backend database is by using ADO.NET technology. But we can have a debate on connected scenario and un-connected scenario in ADO.NET or else we can talk about pros and cons of data controls provided in ADO.NET.
|
|
|
|
|
Dear Mr.Raj,
Thank you very much for your reply.
RangaSL
|
|
|
|
|
ADO works on connected environment whereas ADO.NET(Adapter) will be able to work in disconnected environment.
Regards,
Arun Kumar.A
|
|
|
|
|
Dear Mr.Arun,
Thank you very much for your reply.
RangaSL
|
|
|
|
|
Hey gurus,
I have 2 threads, both of them are calling a method which is connecting to database and reading data.
Here is the thread function.
Everything is okay first thread. But, while calling SqlConnection.Open() from 2nd thread, I am getting exception.
Exception is "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."
But, by default pooling is true with maximum 100 connection. Here I created only one connection from 1st thread. Could you please help me....
Here is my thread fucntion...
<br />
private void StartLoading()<br />
<br />
{<br />
<br />
SqlCommand sqlCommand = null;<br />
<br />
SqlDataReader sqlDataReader = null;<br />
<br />
try<br />
<br />
{<br />
<br />
sqlCommand = new SqlCommand();<br />
<br />
sqlCommand.Connection = new SqlConnection("Data Source=XXX;Initial Catalog=XXXXX;Integrated Security=True");<br />
<br />
sqlCommand.CommandText = " SELECT * FROM table";<br />
<br />
sqlCommand.CommandTimeout = 0;<br />
<br />
sqlCommand.Connection.Open();<br />
<br />
sqlDataReader = sqlCommand.ExecuteReader();<br />
<br />
while (sqlDataReader.Read())<br />
<br />
{<br />
<br />
<br />
}<br />
<br />
}<br />
<br />
catch (Exception ex)<br />
<br />
{<br />
<br />
}<br />
<br />
finally<br />
<br />
{<br />
<br />
if (null != sqlDataReader && !sqlDataReader.IsClosed)<br />
<br />
{<br />
<br />
sqlDataReader.Close();<br />
<br />
}<br />
<br />
if (null != sqlCommand && sqlCommand.Connection.State != ConnectionState.Closed)<br />
<br />
{<br />
<br />
sqlCommand.Connection.Close();<br />
<br />
}<br />
<br />
}<br />
<br />
}<br />
<br />
|
|
|
|
|
How do I return records from a query where a specific field does not have a value. I have a query that will return records if the specific field has a value in it, but if the field does not have a value it does not return in record information. Please advise. Thanks in advance.
|
|
|
|
|
dboy221 wrote: How do I return records from a query where a specific field does not have a value.
SELECT * FROM MyTable WHERE SomeColumn IS NOT NULL
|
|
|
|
|
Colin Angus Mackay wrote: SELECT * FROM
I know this is an easy way to show the example but, being that it is an example, some poor schmo might actually use this in production. Might I suggest:
SELECT SomeColumn1, SomeColumn2 FROM MyTable WHERE SomeColumn IS NOT NULL
Never, never use select * in production.
topcoderjax - Remember, Google is your friend.
|
|
|
|
|
TopCoderJax wrote: I know this is an easy way to show the example but, being that it is an example, some poor schmo might actually use this in production.
Since no columns where given as an example, there was no list from me to select from.
TopCoderJax wrote: Might I suggest
You can suggest it. My my time is limited and I'm not going to spend time writing out a ficitious list only for the OP to come back and say it doesn't work because *I* supplied invalid column names - And that has happened on a number of occasions. Some people are increadibly thick or just don't want to understand what is going on. (NOTE: This is a general observation and may not apply to the current OP)
TopCoderJax wrote: Never, never use select * in production.
I completely agree.
TopCoderJax wrote: Remember, Google is your friend.
And one which most people shun for some bizzare reason. By the way, have you tried to set up a Custom Google Search[^]? It is great you can set filters on it so you get more relevant hits. I've set mine for code project, microsoft and my blog (because half the time I've done it before but I've forgotten how). I get most everything I want in the first couple of hits.
|
|
|
|
|
A well reasoned response, but I guess we'll have to remain in disagreement I've fixed too many programs/stored procedures where this caused problems; It is the equivilent of nails on a chalk board to me... it just makes my skin crawl.
As to this:
Colin Angus Mackay wrote: have you tried to set up a Custom Google Search[^]?
Really cool tip. I can't tell you how many times I wished they would add this feature. Truely appreciated. I'm going to try it out now.
Thanks.
topcoderjax - Remember, Google is your friend.
|
|
|
|
|
Hi,
I don't understand ur question. Give some examples.
If I am right , try this
When column is given NULL
Select isnull(<column>,0) from
When column is given NOT NULL
Select case <column> when "" then "0" else <column> end from
Senthil
|
|
|
|
|
any code sample : unicode into database by store procedure
|
|
|
|
|
Use NVARCHAR or NTEXT to pass the data.
|
|
|
|
|
I'm having difficulty setting up my databinding to allow for a new
record to be inserted. On one side of my form I have a grid with
just a ID and a name (lets say we're doing with People entities) and
on the other is a panel with say 10 diferent textboxes for various
fields (address, phone, etc..) Both the grid, and all detail
textboxes are bound to a bindingsource with a dataview as it's
datasource.
I want the user to be able to click a "New" button, add a new row to
the underlying datasource with it as the current selected row, in edit
mode. The user clicks new, and can begin entering data into the
various textboxes that are bound to the datasource.
My background datatable has various non-null, type, constraint
validations that fail for a new row. I've discovered I can suppress
this with DataTable.BeginLoadData(), but it just doesn't seem wise. I
need to add a "breaking" row to the table, but as soon as a call
Table.Rows.Add() (without the beginloaddata()) it fails immediately.
I can't seem to find an example that does not use a grid control for
in-line editing, or where you do not have the field values ahead of
time. Many examples and articles show this problem, but they require
non-bound controls the user populate and THEN click add new, then they
add the row with the appropriate values - this does not meet my
requirements.
|
|
|
|
|
Hi all,
Is there a datatype "column" in SQL SERver 2000?
If not can we generate user-defined datatype as "column"?
How to convert a variable to datatype column ?
Please reply asap..
Senthil
|
|
|
|
|
What exactly do you mean by datatype column. Is this an object? If you are talking about saving objects in sql I would suggest you serialize the object into xml and save the xml in a text column.
Ben
|
|
|
|
|
Hi,
Thanks for your reply.
I will give an example
Declare @i int
Set @i=1
while @i<=7
Begin
Update set <column> + @i = value
End
In the above example, column name will be dynamic , i.e., column1, column2.
So, I want to use dynamic query for updation. As dynamic query will hit my performance,I need to avoid dynamic query.
Is there any possible way for this?
There is a datatype called table . Similar to that, whether there is any datatype called column?
Senthil
|
|
|
|
|
Certainly if your table doesn't have very much data I would look at doing this in memory. If you are using .net there is a DataTable which you can dynamically create. There are DataColumns which you can dynamically add to the dataTable. Then you can take the devaultview of the datatable and use the rowfilter to query the table's data.
In sql 2000 and 2005 there are table variables, but they only stick around for the duration of the stored procedure so you probably want it to be around a little longer then that.
If there aren't too many rows and columns I would think seriously of keeping the data in an internal table in your program.
Ben
|
|
|
|
|
I am using such type of query in a stored procedure.
My stored procedure is compiled each time when it is executed.
I am in a position to remove those dynamic queries to get my stored procedure execute faster.
I hope u understood. If not I can explain some more.
Senthil
|
|
|
|
|
Perhaps it would be better to explain exactly what you are trying to do. Why do you need a dynamic query? Why do you need to create a table? If you dynamic query returns certain columns you can just return those columns in the result set and your program can read them. The only issue because how your program knows what to do with the columns.
Ben
|
|
|
|
|
Hi, I have a form that I am using (MS Access) and it needs to be able (when clicking a command button) to take a value from a text field, alter an already created table by adding a column with that text field name, but also populate that column with checkboxes. Right now I can add the column, with the Yes/No data type, however in the table, instead of checkboxes I have to give a value of 0 (false) or -1 (true). Is it possible for SQL to do this?
-
reegan41
|
|
|
|
|
I believe the "checkbox columns" you are referring to are a "feature" in MS Access where in the table view yes/no fields are displayed as checkboxes. I imagine Access allows this because it is a user/desktop database and editing table data directly is a desired feature. SQL Server is not a user/desktop database and SQL Server administrators often go to great lengths to prevent users from opening up a table and editing it. Microsoft also recommends not doing it as well. Hence, the checkboxes will not show when you open up a table to view the data. That said, you can write an application (which could be using MS Access as a front-end) that displays that data type as a checkbox.
|
|
|
|