|
No problem
The need to optimize rises from a bad design.
My articles[ ^]
|
|
|
|
|
Is it possible to do a dataview.Sort with part of a column? I have a datatable with 4 columns. I need to sort off the first column, but only off the first 4 characters, like this:
ORDER BY LEFT(ScheduleID,4) DESC
The above order by is valid in SQL, but doesn't appear to work in the dataview.sort using "LEFT(ScheduleID,4) DESC". Of course "ScheduleID DESC" works, but I don't get the desired results.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
No, it's not. You'd have to split the values in that column into another column with just the data that's valid for the sort, then sort on this column.
But, as you've found out, it's easier to do on the database side, and it'll have far better performance too.
|
|
|
|
|
Unfortunately, I'm building the datagridview rows from reading in a text file.
Your idea about adding a hidden sort column is brilliant!
Thanks Dave.
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|
|
I am having trouble finding documentation on how to, using Vb.net to read a png file into a string and convert to Hex.
Dow anyone have any code examples for me? Thank you
|
|
|
|
|
What do you mean by "reading a png file into a string and convert to Hex"??
Any file is just a stream of byte values, 0x00 thru 0xFF. Converting those to Hex is as easy as using String.Format("{0:X2}", value) to return a single value as a Hex string. What you do with those strings is up to you.
|
|
|
|
|
I am reading the png like this. (I don't know if this is the best way.
Dim ascii() As Byte = File.ReadAllBytes("C:\3604.png")
I want to put This into a string.
dim str as string = String.Format("{0:X2}", ascii) Does not work.
Is there an easy way besides looping through each byte and copying it to string?
|
|
|
|
|
Cory Kimble wrote: dim str as string = String.Format("{0:X2}", ascii) Does not work.
Sure it does, when you convert each and every byte in the array, individually. You can't send an array to Format and expect it to iterate over the array for you.
Cory Kimble wrote: Is there an easy way besides looping through each byte and copying it to string?
Nope. That's the only method you have.
|
|
|
|
|
Hi,
I wotre years ago in vb6 a database for music. I want to convert the whole program into VB.net 2008.
The original program was with cddb from gracenote.
The question now is is there support for .net by gracenote or is there something beter/easyer but with the same functions?
Like seeing what cds is in the drive, editing mp3 tags
If posible also support for DVD(music/films/series)
Jan
some examples from the new system are welcome
|
|
|
|
|
There's a GPL service called FreeDB[^] now.
|
|
|
|
|
What must I download?
I think the server software but thats only in C
Jan
|
|
|
|
|
Hi,
I am trying to add a 3rd party dll(C++) to my application which is created on vb.net. when i tried to add that dll as reference i got a error as "A reference to <file location=""> could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component."
When i checked this in online, it seems to be unmanged code which is not accepted by .net and also they said P/Invoke command something like that.
But actually i dont know how to register a dll or use Pinvoke method or how i add a unmanged dll into my application, Can anyone help in this.
Thanks,
Nanda
|
|
|
|
|
Register a dll using regsvr32.exe. Do you know the functions exported by the dll?
|
|
|
|
|
Thanks JZ, But again.
how to do that with regsrv32.exe, for example my dll name is nanda.dll, where i have to do this and how and what was the output
Thanks,
Nanda
|
|
|
|
|
REGSVR32 filename.dll
But, if the .DLL is not COM-based, this wont work and you'll be forced to use P/Invoke to call the functions in the .DLL. You will not be able to set a reference to it and have VS import the functions for you.
|
|
|
|
|
Thanks Dave,
I tried but It throws a message box
<dll> was loaded, but the DllRegisterServer entry point was not found.
This file can not be registered.
I hope this dll is not com based
Can you please help me how to use P/Invoke with an example.
Thanks,
Nanda
|
|
|
|
|
You got that error because the .DLL is not COM-based. You'll have to use P/Invoke to get at the functions in that library. I hope you have the documentation on it.
http://www.pinvoke.net[^] has tons of examples.
|
|
|
|
|
Hi
I created store produce to insert selected values from checkboxlist into sql database and it gives me this error "Procedure or function SaveAdmin has too many arguments specified."
here is my store procedure
ALTER PROCEDURE [dbo].[SaveAdmin]
-- Add the parameters for the stored procedure here
@Perno int,
@Client_id int,
@Region_id int,
@Service_id int
AS
INSERT INTO Admin(Perno, Client_id, Region_id, Service_id)
VALUES(@Perno, @Client_id, @Region_id, @Service_id)
and here is my vb.net code
cmdStandby.CommandText = "SaveAdmin"
cmdStandby.CommandType = CommandType.StoredProcedure
cmdStandby.Connection = sqlstandby
cmdStandby.Parameters.AddWithValue("@Perno", lblEmpNo.Text)
cmdStandby.Parameters.AddWithValue("@Client_id", ddlClient1.SelectedValue)
For Each li In ChkRegion.Items
If li.Selected = True Then
cmdStandby.Parameters.AddWithValue("@Region_id", li.Value)
End If
Next
For Each li In ChkService.Items
If li.Selected = True Then
cmdStandby.Parameters.AddWithValue("@Service_id", li.Value)
End If
Next
cmdStandby.ExecuteNonQuery()
thanx in advance
Mamphekgo
|
|
|
|
|
Hi, I have never used add with value but I assume it adds the parameter to the collection as well as adding the value. Try using .value =
Even if that worked you would still only get one 'set'passed through as your loops are replacing the value each iteration. Your executenonquery needs to be inside the loop, and the loop needs to add each type of value to the set.
Looking at what you are trying to do I suspect that you should be normalising the database a bit more, unless you want each row to contain the employee and client data for each service ID and region ID
Sort of like: (I don't think this is quite right as I an not sure what you controls are but you should get the idea)
cmdStandby.CommandText = "SaveAdmin"
cmdStandby.CommandType = CommandType.StoredProcedure
cmdStandby.Connection = sqlstandby
cmdStandby.Parameters.Add("@Perno", SqlDbType.Int)
cmdStandby.Parameters.Add("@Client_id", SqlDbType.Int)
cmdStandby.Parameters.Add("@Region_id", SqlDbType.Int)
cmdStandby.Parameters.Add("@Service_id", SqlDbType.Int)
For Each li In ChkRegion.CheckedItems
cmdStandby.Parameters("@Perno").Value = CINT(lblEmpNo.Text) 'or the proper conversion
cmdStandby.Parameters("@Client_id").Value = ddlClient1.SelectedValue 'or should this be selected index? If value what is it ? Text, integer etc
cmdStandby.Parameters("@Region_id").Value = li.Value '(?)
cmdStandby.Parameters("@Service_id").Value = li.Value '(?)
cmdStandby.ExecuteNonQuery()
Next
For Each li In ChkService.CheckedItems
cmdStandby.Parameters("@Perno").Value = CINT(lblEmpNo.Text) 'or the proper conversion
cmdStandby.Parameters("@Client_id").Value = ddlClient1.SelectedValue
cmdStandby.Parameters("@Region_id").Value = li.Value '(?)
cmdStandby.Parameters("@Service_id").Value = li.Value '(?)
cmdStandby.ExecuteNonQuery()
Next
|
|
|
|
|
Is suspect your problem is here:
For Each li In ChkService.Items
If li.Selected = True Then
cmdStandby.Parameters.AddWithValue("@Service_id", li.Value)
End If
Next
This loop is going through a list and checking if it's selected. For each value selected you're adding another parameter (with the same name) to the Parameters collection. If there is more than one item selected, your code is adding more than the 4 parameters to the SQL call.
|
|
|
|
|
hi,
Is there any free activex component that support secure ftp?
|
|
|
|
|
|
Does anyone knows how to share the value of a particular variable but are declared in different class?
|
|
|
|
|
declare the variable as shered variable so it can be accessed and modified. For example
Public Class Utility<br />
Public Shared SharedVariable As Integer<br />
End Class
hope this helps
|
|
|
|
|
Use a property
Dim strVar As String = "la la la"
Public Property SharedMyVariableWithTheWorld() As String
Get
Return strVar
End Get
Set(ByVal value As String)
strVar = value
End Set
End Property
Any suggestions, ideas, or 'constructive criticism' are always welcome.
|
|
|
|