|
Hi Pankaj,
While I do appreciate your suggesting using increment property instead of random, I've tried that before but I decided to use random number as customer ID because those random numbers are hard to guess and they can be used to retrieve customer's password in case he/she forgets one. My only problem is sometimes the autonumber creates negative integers, and also the numbers aren't always of a fixed length. If you (or anyone else reading this) could suggest me a better solution, I'd greatly appreciate it. Thanks.
Anjani Shiwakoti
Computer programs and social cultures are the same.
|
|
|
|
|
And what happens if suddenly you get a random number that already exists?
Use an autonumber column and keep the ID private to the application. And to let the user retrieve his password, ask him for an email address during signup and send it to that email address.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
Hi Luis,
While I do appreciate your suggestion, I've decided to seed a random postive integer with a fixed length right from my .aspx page, instead of letting MS Access create it for me. I guess that takes care of it. BTW, I don't think that random autnumber will 'suddenly' create a number that already exists in the database. It guarantees that every number it creates will be unique.
Anjani
Computer programs and social cultures are the same.
|
|
|
|
|
Hi Guy's
i have problem in finding highest value from two column
eg.
i have table 'MyTable' with Column 'ID','Column1','Column2'
which contained data as
ID Column1 Column2
01 100 102
02 50 60
I want to find out the highest value of 'ID' 02 of this two column (i.e. 60) in SQL Query
Sasmi
|
|
|
|
|
SELECT MAX(ID) FROM MyTable
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"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
|
|
|
|
|
i dont want the maximum value from the ID column
i want to find out the highest value for a perticuler row in different columns i.e. if i have table with two columns Column1 and column2
Column1 has three rows with values 100, 45, 50
Column2 has three rows with values 101, 25, 40
now i want to find the higest value in first row of Column1 and Column2 which is 101 similarly for second row highest value is 45 and theird row highest value is 50.
so how do i go about doing this
Sasmi
|
|
|
|
|
SELECT ID, CASE WHEN Column1 > Column2 THEN Column1 ELSE Column2 END as Highest
FROM MyTable
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"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
|
|
|
|
|
hi
I like to select certain number of records in the range format from 100 to 200 from the table with condition and displayed in the query analyzer .Which is the best way to achieve it .Earlier I was using Top 200 * from tablename1 where condtion but it is not helping me to get the desired result .
Any other format to retrieve records from the table .A single table is having thousand of records.Using select column names with condition also proved fatal numerous of records are coming
any good query for this
sasi
|
|
|
|
|
http://www.google.com/search?sourceid=navclient&ie=UTF-8&rls=GGLD,GGLD:2005-32,GGLD:en&q=sql+server+paging
|
|
|
|
|
I am trying to expand my knowledge of SQL and I am using the MSDE. I am trying to add/import the Northwind database to this server, but I am lost on what to do?? Could someone give me some help?
thanx in advance,
Jude
|
|
|
|
|
Any particular reason for MSDE? SQL 2005 Express is good and SQL Server Management Studio Express CTP makes administering it easy.
Paul
|
|
|
|
|
from what I know 20005 isn't comaptible w/ VS.net 2003
|
|
|
|
|
This is what I did with MSDE. I use a program called DbaMgr V0.55.1 (a free wanna-be Enterprise Manager). I don't remember the link to the program, but I am sure it's one of the first hits one can find get on google. You can use DbaMgr to setup the Northwind database.
I hope this helps,
Paul
|
|
|
|
|
Thanx alot! Worked like a charm!
|
|
|
|
|
TheJudeDude wrote: Worked like a charm!
I am glad I was able to help you.
Have fun getting your feet wet with MSDE.
Paul
|
|
|
|
|
ok, so really, Here's the error message:
"Failed to Connect to the Database!Timeout expired. The timeout period elaspsed prior to obtaining a connection from the pool. This may have occurred because all polled connections were in use and max pool size was reached. at
System.DataSqlClient.SqlConnectionPoolManager.GetPolledConnection(SqlConnectionString options, Boolean&isInTransation)
at System.Data.SqlClient.SqlConnection.Open()
at WindowsApplication1.Form1.dbConnect() in c:\documents and settings\user1\desktop\windowsApplication\form1.cs:line2957"
what do i need to do...i'm enumerating thru a treeView and using the node.text as a servername to create a connection to each pc(treenode). It looks like the connections to the pc's are happening much quicker than the db can store...is this possible?
anyhow i could use some help....
thanks
string Beautiful;
Beautiful = "ignorant";
label1.Text = "The world is full of " + Beautiful +" people.";
Why is common sense such an un-common comodity?
|
|
|
|
|
Are you making sure that you close connections when you are done with them? (By that I mean that the close goes in a finally block so that it happens regardless of any exceptions that might be thrown (caught or not)
wetrivrrat wrote: WindowsApplication1.Form1.dbConnect()
I'm assuming by the naming here that this is a quick throw away application. If not, you should consider layering the application so that add data access happens in a data layer (a set of classes that are decoupled from the user interface). Or, to put it another way: You should not be doing any database interaction from your form class.
ColinMackay.net
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
"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
|
|
|
|
|
actually, at this point its working...i found a piece of code that i accidently commented out....
string Beautiful;
Beautiful = "ignorant";
label1.Text = "The world is full of " + Beautiful +" people.";
Why is common sense such an un-common comodity?
|
|
|
|
|
How to sort a column in data grid:
I want to sort on the column "LoanNumber"
In my ASP code shown below, I added AllowSorting property to True, in the
DataGrid.Which gives me the hyperlink in the header.
In order to have this happen I need to do two things: create a
sort event handler and specify the event handler for the
DataGrid's sort event.
I created the sub SortEventHandler as below but I am lost as to
what is next to do?
Sub SortEventHandler(sender as Object, e as DataGridSortCommandEventArgs)
...
End Sub
<asp:datagrid id="DG1" runat="server" backcolor="Gainsboro" autogeneratecolumns="false"
onitemcommand="DGColumnBtn"
="" width="512px" allowsorting="True">
<edititemstyle backcolor="Red">
<alternatingitemstyle backcolor="#C0FFFF">
<headerstyle backcolor="Silver">
<alternatingitemstyle backcolor="White">
<columns>
<asp:buttoncolumn text="Details" headertext="Credit Life" buttontype="PushButton">
<asp:boundcolumn datafield="clid" visible="False">
<asp:boundcolumn datafield="CLMaturityDate" dataformatstring="{0:MM-dd-yyyy}" headertext="MAT Date">
<asp:boundcolumn datafield="LoanNumber" headertext="LoanNumber" sortexpression="LoanNumber">
<asp:boundcolumn datafield="Loanamount" headertext="Amount">
Private Sub DG1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DG1.SelectedIndexChanged
End Sub
|
|
|
|
|
kenn_rosie wrote: I created the sub SortEventHandler as below but I am lost as to
what is next to do?
You will probally get an answer in the correct form try the Web Devolopment form[^]
Good luck
BTW, if you wanted to sort the data before presenting it to the user use the Order By [column] in your select statement.
|
|
|
|
|
Hi,
I wonder if there is any limitation concerning the length of a sql statement.
I have the following situation:
I need to update a single column of a lot of records in a table.
Updating those 20K (20000) records one at the time consumes a lot of time.
In order to speed things up I collect those queries to create one big SQL statement.
Now the problem is the following whenever I place more that 455 update queries only the
first 455 are executed. The others are neglected, because no error has happened (neighter
in my try/catch block or in the SQL Server checked with the profiler). The size of the
sql statement (455 queries) is about 20Kb in size.
Any thoughts on this would be very appriciated
BTW:
I'm developing in VC++ 2005
on a SQL Server V2000
codito ergo sum
|
|
|
|
|
BadKarma wrote: Updating those 20K (20000) records one at the time consumes a lot of time.
In order to speed things up I collect those queries to create one big SQL statement.
Now the problem is the following whenever I place more that 455 update queries only the
first 455 are executed. The others are neglected, because no error has happened (neighter
You did what???
You have a big problem in your design. Like you've found out, if one statement fails, you have to consider the entire batch a failure. You can't catch an error because nothing throws one.
Best practice says that you call a stored procedure on the SQL Server to do the update for you and just pass the parameters to it, 20,000 times. The stored procedure can check to see if the update works and RAISEERROR if it failed for some reason. You can catch that error in your code. You also get the benefit of knowing exactly which one of these calls failed.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote: if one statement fails, you have to consider the entire batch a failure
I know for certain that all queries are valid. If I execute 400 of them in batch there is no
problem, even 455 of them. Only when I exceed the 455 queries 'limit' in the batch, then the last are neglected.
Due to what reason can a valid query be neglected ???
codito ergo sum
|
|
|
|
|
Because the query IS invalid, the last lines are being cut off. There is a limit to the size of a query string you can pass. I think it's 8192 bytes, but I can't find solid documentation on it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
First of all thanks for your time too reply.
The queries i execute look like this:
UPDATE MyTable SET MyField = 1 WHERE Data = 1;
UPDATE MyTable SET MyField = 1 WHERE Data = 2;
UPDATE MyTable SET MyField = 1 WHERE Data = 3;
UPDATE MyTable SET MyField = 1 WHERE Data = 4;
this goes on up until Data reaches 1000.
So like you can see the size of the query is relative small not even 50 characters.
The batch statement though, can reach the size of more the 20k of characters but shouldn't be
a problem because the max bacth size is 65536 * network packet size (see response from Sl0n[^])
When I execute this batch to an limit of 455 queries, there is no problem. The size of this batch is over 8192 byte limit (its arround 18K). When I add more queries to the bacth every query past this 455 limit just doesn't get executed and the batch statement is returned as a success.
So even though I stay well under the limits, those queries aren't executed ???
Or do I miss something?
codito ergo sum
|
|
|
|