|
So why not just fetch this value from the database??
SELECT COUNT( DISTINCT( CityName ) ) AS DistinctCities FROM myTable
|
|
|
|
|
Thank you for replying.
Although i might fetch the COUNT of distinct cities from the
database, how am i going to segregate records after fetching them into the data table. I will definately know how many distinct cities exist, however i am unable to find a way to filter out those records depending upon city names, into seperate tables. (Again hard coding of city names to segregate records is not possible!)
I was just trying to know if there exists a pre-defined function to do such a thing.
I guess i will have to mull over it to find a logic of my own.
Thank you all for taking the time out to think over it though.
Siddy
|
|
|
|
|
This is too easy. If you can get the count of DISTINCT cities, you can just remove the COUNT function from the exact same SQL statement to get the entire list of distinct city names.
|
|
|
|
|
hi guys;
it s a little difficult ;idont wanna get the Max value of all but Max-values between the blocks.
this code below serve to get the max value
<br />
For zahl = 0 To Intens_Array.GetUpperBound(0)<br />
If Intens_Array(zahl) = 0 Then<br />
Max = 0<br />
Else<br />
If Max < Intens_Array(zahl) Then<br />
Max = Intens_Array(zahl)<br />
End If<br />
End If<br />
Next<br />
thats easy; but what i want is to get the Max value between each block of zero-values;
look here: i have an array with the values like
00000041932321459000000076384600000323453200000
my question is, how could i get the max VALUES whithin each block and his index in this arry for this example will be like:
9-->index:17
8-->index:28
5-->index:40
i hope i was clear;
so let me know pls )
thx all
|
|
|
|
|
<br />
Dictionary<integer, integer=""> dictMaxAndIndex = new Dictionary<integer, integer=""><br />
For zahl = 0 To Intens_Array.GetUpperBound(0)<br />
If Intens_Array(zahl) = 0 Then<br />
dictMaxAndIndex.Add(Max, zahl)<br />
Max = 0<br />
Else<br />
If Max < Intens_Array(zahl) Then<br />
Max = Intens_Array(zahl)<br />
End If<br />
End If<br />
Next<br />
</integer,></integer,>
I added a dictionary of two integers. The first keeps the max value, the second it's index... You can now loop through the dirctionary to get it's values...
|
|
|
|
|
first thx for this help;,so i try it but it doesnt work?? this my code:
<br />
Dim Intens_Array() As Double = {0, 0, 0, 0, 0, 0, 2, 3, 9, 8, 1, 4, 5, 0, 0, 0, 0, 0, 0, 0, 5, 4, 9, 4, 8, 4, 3, 0, 0, 0, 0, 0, 0, 5, 4, 3, 2, 2, 6, 0, 0, 0}<br />
Dim Intens_Array1() As Double<br />
Dim Max As Integer = 0<br />
Dim zahl, zahl1 As Integer<br />
Dim Index As Integer = 0<br />
Dim dictMaxAndIndex As New Dictionary(Of Int16, Int16)<br />
<br />
'Dictionary(dictMaxAndIndex = New Dictionary)<br />
For zahl = 0 To Intens_Array.GetUpperBound(0)<br />
If Intens_Array(zahl) = 0 Then<br />
dictMaxAndIndex.Add(zahl, Max)<br />
Max = 0<br />
Else<br />
If Max < Intens_Array(zahl) Then<br />
Max = Intens_Array(zahl)<br />
End If<br />
End If<br />
Next<br />
For zahl1 = 0 To dictMaxAndIndex.Count - 1<br />
Console.WriteLine("For key = ""3"", value = {0}.", _<br />
dictMaxAndIndex("3"))<br />
Next<br />
System.Console.ReadLine()<br />
what i want is to put the max values with her indexes in this dictionary ; no zeros!!zeros have to be ignored. so like, hope its clearly??
thx for help.
|
|
|
|
|
'Dictionary(dictMaxAndIndex = New Dictionary)
For zahl = 0 To Intens_Array.GetUpperBound(0)
If Intens_Array(zahl) = 0 Then
If (Max > 0)
dictMaxAndIndex.Add(zahl, Max)
Max = 0
Else
If Max < Intens_Array(zahl) Then
Max = Intens_Array(zahl)
End If
End If
Next
For zahl1 = 0 To dictMaxAndIndex.Count - 1
Console.WriteLine("For key = ""3"", value = {0}.", _
dictMaxAndIndex("3"))
Next
System.Console.ReadLine()
|
|
|
|
|
I am working with a word plugin. It checks all words in a document against a dictionary. After a check some words are coloured depending on if they are ambigues or not recommended. A right-click on a coloured word opens a popup with a list of recommended words. The user clicks on a recommended word in the popup window and the coloured word will switch to the recommended and the colour will change. The user can press ctrl+z and undo the change. I have to monitor ctrl+z and put the right colour on the word. How do I monitor ctrl+z in a word document?
|
|
|
|
|
Hi,
I am using webclient to download file from another location.
I am downloading swf file.
while downloading swf file it shows size of file less than the origional size.
I want to download swf file that has same size that of origional.
Thanks
|
|
|
|
|
if it works, why does the size matter ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I have two databales which i have merged then i am trying to update the database through commandbuilder
here is the code. Everything goes fine but values are not inserted in database table
Public Function SaveOracleDBInfo(ByVal OracleDT As DataTable, ByVal TableName As String) As Boolean
Dim sqcn As New SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("ConnectionString").ToString)
Dim sqcd As New SqlClient.SqlCommand("select DB_VC200_TableSpace NAME,DB_VC200_Status STATUS,DB_DC9_Size Size,DB_VC500_Path 'File Location' from T170016", sqcn)
Dim dt As New DataTable
Dim sqad As New SqlClient.SqlDataAdapter(sqcd)
Try
sqad.MissingSchemaAction = MissingSchemaAction.AddWithKey
sqad.Fill(dt)
dt.Merge(OracleDT, True)
Dim sqcmdb As New SqlClient.SqlCommandBuilder(sqad)
sqad.Update(dt)
Catch ex As Exception
Finally
sqad.Dispose()
End Try
End Function
|
|
|
|
|
nitin_ion wrote: dt.Merge(OracleDT, True)
After this merge, are the records in the DataTable's Rows collection still tagged as Unchanged? Look at the Rows collection, and at the RwoState property of each DataRow object in it. If they're all tagged Unchanged, the DataAdapter that writes this data back to the database will think that the row does NOT need to be updated in the database and won't write the changes.
|
|
|
|
|
hi all
I am working on vb.net window application where i am using adobe acrobat 7.0 browser to open pdf inside the browser. I want to disable the mouse scroll.I can remove the scroll bar but the mouse scroll button still works . so that user should be able to see only the page that is specified ( i don't want user to scroll to other pages in pdf). Can any one tell me how to disable the mouse scroll button on pdf browser
Thanks and Regards
Prakash Mishra
Prakash Mishra(Banglore,India)
|
|
|
|
|
Well, if you're using a web browser control in one of your forms to do this, I guess you could override your form's WndProc method and look for WM_SCROLL messages and just eat 'em. By that I mean not passing them on to the form's base WndProc method.
Another option might be to use a 3rd party library to render the PDF file, like PDFNet. This would also eliminate the dependancy on the web browser control and give you greater flexibility over what the user can see.
|
|
|
|
|
Hi All,
In my vb application, I am generating data from database and retriving it and placing it in MSFlexgrid which includes date column also.
And I am using the following code to convert the data from MSFlexgrid to Excel.
But in that, in Date column is in properly coming in MSFlexgrid. But when we convert it to Excel, some of the dates (like 12/03/2008, 11/03/2008,04/03,2008..I hope all the dates less than or equal to 12) will be converted like 03/12/2008, 03/04/2008, 03/11/2008...like this. But the other dates 25/03/2008...is populating in Excel correctly.
Please help me how to overcome this issue.
Dim xlObject As Excel.Application
Dim xlWB As Excel.Workbook
Set xlObject = New Excel.Application 'This Adds a new woorkbook, you could open the workbook from file also
Set xlWB = xlObject.Workbooks.Add
Clipboard.Clear 'Clear the Clipboard
With MSFlexGrid1 'Select Full Contents (You could also select partial content)
.Col = 0 'From first column
.Row = 0 'From first Row (header)
.ColSel = .Cols - 1 'Select all columns
.RowSel = .Rows - 1 'Select all rows
Clipboard.SetText .Clip 'Send to Clipboard
End With
With xlObject.ActiveWorkbook.ActiveSheet
.Range("b2").Select 'Select Cell A1 (will paste from here, to different cells)
.Paste 'Paste clipboard contents
End With ' This makes Excel visible
xlObject.Visible = True
Thanks in Advance,
Regards,
R. Sangeetha Priya
|
|
|
|
|
hi the way u r submitting the date and retrieving it may be there is the problem try this it may help
Dim signDate As String = Format(DateTimePicker2.Value, "MM/dd/yyyy")
Regards
Prakash Mishra(Banglore,India)
|
|
|
|
|
Hi,
Thanks.
The date is getting saved in "dd/mm/yyyy" format in database as well as its populating in msflexgrid in dd/mm/yyyy format.
But when try to convert it to excel, in this case only some of the dates formating is changed. Especially the dates from 1-12 is getting interchanged the month and date places.
Please help me how to format the cell so that it gets only in dd/mm/yyyy format, or suggest me some ideas to overcome this.
Regards,
|
|
|
|
|
I suspect its the cell format in Excel thats causing your problem. If the cell is not defined as a date format then it will display dates in what appears to be an odd format. Try applying a format to your cell and I suspect it will be all OK.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
hey u can do one thing
in excel select the column in which u r showing the date, then click on for example A column so that the entire A column gets selected then right click and select format cell then click the tab number then select date then set the format as per ur wish it will set the property for that column permanently.
hope it helps
Prakash Mishra(Banglore,India)
|
|
|
|
|
Hi,
I am getting the error using the below code:-
In the While Loop after reading first records the error comes.
I am checking file extension in the if else loop within while loop.
if file extension is swf then I am calling DownloadSwfFle function.
DownloadSwfFle function where I am opening and closing connection to get some swf related information that is stored in another table.
else then other extension will be there then else part run.
my table contains 2 records in which 1st file contains swf extension.
If (conn.State = ConnectionState.Open) Then
conn.Close()
End If
conn.Open()
cmd = New SqlCommand("select * from table1 where = " & id, conn)
dr = cmd.ExecuteReader
While dr.Read
If filext(1) = "swf" Then
Call DownloadSwfFle(merchant_id)
Else
Dim filepath As String = dr("file_path")
If Not File.Exists(localpath & filename) Then
Dim oRead As System.IO.StreamReader
oRead = oFile.OpenText(Application.StartupPath & "\url.txt")
Dim url As String = oRead.ReadLine
Dim myStringWebResource As String = Nothing
Dim myWebClient As New WebClient
myStringWebResource = url & filepath
myWebClient.DownloadFile(myStringWebResource, localpath & filename)
End If
End If
End While
cmd = Nothing
dr = Nothing
conn.close()
|
|
|
|
|
sjs4u wrote: cmd = New SqlCommand("select * from table1 where = " & id, conn)
You'r SQL statement is malformed. The WHERE clause doesn't specify a valid expression for matching records. "WHERE = something " isn't valid. You need to change this so it looks like "WHERE someColumn = something ".
Beyond that, your code is an incomprehensible pile of spaghetti. I suggest cleaning it a bit so that the logic is laid out better and some of this is broken up into their own methods, like the SQL code.
|
|
|
|
|
How to delete data in a table which multiselected rows from a DataGridView?
|
|
|
|
|
how is the grid populated ? If from a datasource, probably remove from the source and rebind.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I have been trying to add System.IO.Ports to VB 2003. I have tried using framework 2.0, but it won't let me and earlier versions don't have it in the System.dll. Anyone have any ideas?
Thank You,
Brian
|
|
|
|
|
Seeing as it was new in 2.0, it's not gonna be there in 1.1 or 1.0, right ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|