|
Hi
I have a sql statement which is in my c# code.
How would I write the following though
Select * from table where field contains a certain value
e.g. select these values from the table
v1106~066
v1106~066_01
where as at the moment it just selects:
v1106~066_01
my current sql statement is select..... LIKE '" + s_number + "'" +
s_number is the value v1106~066_01
thanks!!!
hope it makes sense
|
|
|
|
|
sorted it:
"'+ session_room_code + "%'"+
|
|
|
|
|
In order to match against multiple records, you need to apply the wildcard characters in your search. In other words, you need to use v1106~066% to retrieve the two records. A couple of thoughts though.
1. You shouldn't retrieve all of the columns using *. That's just lazy coding and should be avoided at all costs.
2. You've left yourself wide open to a Sql Injection attack. Read this[^] article.
|
|
|
|
|
I'm not actually using Select * i just put it there becasue I couldnt be bothered to write out all of the fields i was selected which ironically makes me lazy
|
|
|
|
|
Jamie1985 wrote: I'm not actually using Select * i just put it there becasue I couldnt be bothered to write out all of the fields i was selected which ironically makes me lazy
OK. Nice one.
|
|
|
|
|
Thats just a great answer...
|
|
|
|
|
I am working on Generating the Code automatically using CodeDom.
How can I create a solution file and project file through Code.
Ashwani
|
|
|
|
|
I am afraid solution and project files are not covered by CodeDom, as they are Visual Studio specific, and not part of C#. You could probably use Visual Studio object model, or create these by yourself - they are text files after all. Or get SharpDevelop source and see there.
[ My Blog] "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
how to apply different color for datagrid columns.which property can be set for this.i have set the background of the header with an image.i want to set different color for all the columns.can anyone help me in this regard.
pintoo
|
|
|
|
|
This should help you. You will have to modify it for use, however. That way you will have to do a little work . This method takes a row index, then loops through the columns for that row in the dataGridView , and then sets the backround color to light gray.
private void HighlightSelectedRow(int iRowIndex)
{
for (int c = 0; c <; yourDataGridView.Columns.Count; c++)
dataGridView1[c, iRowIndex].Style.BackColor = Color.LightGray;
}
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
Hi
How to include a chm file into a .net application and how to associate the index of the chm file to the form in the application.
Any one who knows the solutions please help me do this.
Thank you in prior.
|
|
|
|
|
Use HelpProvider component in Visual Studio 2005.
-Dave.
Dave Traister,
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
Hi,
I am trying to install a .pfx certificate in personal folder using a C# application. Every thing goes fine and certificate is installed. I can see that certificate in the Personal folder of both Current User and Local machine. But when i try to run my application and use that certificate, it throws exception with the message:
The credentials supplied to the package were not recognized
Stack Trac at System.Net.SSPIWrapper.AcquireCredentialsHandle(SSPIInterface SecModule, String package, CredentialUse intent, SecureCredential scc)......
But when i import this cert manually, it works just fine. Below is the code i am using for installing the certificate:
Dim cert_personal As X509Certificate2 = Nothing<br />
Try<br />
cert_personal = New X509Certificate2<br />
cert_personal.Import(Application.StartupPath & "\Chain\Personal.pfx","My Password" , (X509KeyStorageFlags.UserKeySet Or X509KeyStorageFlags.Exportable))<br />
Catch ex As Exception<br />
MsgBox(ex.Message)<br />
End Try<br />
If cert_personal Is Nothing Then<br />
Return False<br />
End If<br />
<br />
''XXXXXXXXXXXXXXXXXXXXXXXX PERSONAL XXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br />
Dim store As New X509Store(StoreName.My, StoreLocation.CurrentUser)<br />
Try<br />
store.Open(OpenFlags.ReadWrite)<br />
Dim findVal As String = cert_personal.Thumbprint 'Thumbprint <br />
Dim certColl As X509Certificate2Collection = store.Certificates.Find(X509FindType.FindByThumbprint, findVal, False)<br />
<br />
If certColl.Count <= 0 Then<br />
store.Add(cert_personal)<br />
<br />
End If<br />
Catch ex As Exception<br />
MsgBox(ex.Message)<br />
Finally<br />
store.Close()<br />
End Try<br />
<br />
And almost same for installing in Local machine. The complete chain is also fine. But the problem is still there.
I can't use CertMgr since this cert is from a third party which is not , as per my info, supported by that.
Any suggestion, code sample, advice would be highly appreciated.
Thanks in advance,
Wasif Ehsan.
|
|
|
|
|
Has anyone been successful in impementing the ObjectPicker dialog and getting
additional attributes by using C# + Interop?
The problem comes in when you need to marshal the string array and while reading
the attribute values back ino the managed code.
Thank you very much for any advise here.
Thanks,
...G.
|
|
|
|
|
hi
how can i get the Battery and Memory Level in C# code for PPC ?
how can i make Sounds in c# code for PPC ?
thanks alot for any Help
|
|
|
|
|
pls help me with the code for A* algorithm for finding the shortest path between two points
|
|
|
|
|
|
Member 4756709 wrote: the shortest path between two points
Is a straight line.
Couldn't resist....
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Only on a 2D/3D surface. In 4D spacetime, it's a geodesic.
Cheers,
Vikram.
"If a trend is truly global, then that trend ought to be visible across ANY subset of that data" - fat_boy
|
|
|
|
|
Wasn't me that gave your the 1 vote...
Doesn't Pythagoras work in any number of dimensions? The geodesic would just be a visualization of it, right?
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Pythagoras is only correct in euclidean geometry. It's not the number of dimensions that matters, it's the flatness that does. In flat space a geodesic is a strait line. In curved space a strait line isn't always the shortest path.
Otherwise [Microsoft is] toast in the long term no matter how much money they've got. They would be already if the Linux community didn't have it's head so firmly up it's own command line buffer that it looks like taking 15 years to find the desktop.
-- Matthew Faithfull
|
|
|
|
|
hmm....the straight line is always not possible with blockages along the path between source to the exit...i dont want the shortest path b/w two points but the shortest out of every available path....
|
|
|
|
|
Try here[^]. Lots of A* implementations are there
[ My Blog] "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
Hi all. I have project compress file using C#. I'm using name space IO.Compression and i saw this code on Internet but it is compress to file bigger than source file. Can you help me, please.Thanks for your help.
<br />
public void CompressFile(string inputFileName, string outputFileName)<br />
{<br />
byte[] buffer = new byte[4096];<br />
if (File.Exists(inputFileName))<br />
{<br />
using (FileStream inputFile = File.Open(inputFileName, FileMode.Open), outputFile = File.Create(outputFileName))<br />
{<br />
<br />
using (GZipStream gzip = new GZipStream(outputFile, CompressionMode.Compress))<br />
{<br />
int n = 0;<br />
while ((n = inputFile.Read(buffer, 0, buffer.Length)) != 0)<br />
{<br />
gzip.Write(buffer, 0, n);<br />
}<br />
}<br />
}<br />
}<br />
}<br />
<br />
<br />
public void UncompressFile(string inputFileName, string outputFileName)<br />
{<br />
byte[] buffer = new byte[4096];<br />
if (File.Exists(inputFileName))<br />
{<br />
using (FileStream intputFile = File.Open(inputFileName, FileMode.Open), outputFile = File.Create(outputFileName))<br />
{<br />
using (GZipStream gzip = new GZipStream(intputFile, CompressionMode.Decompress))<br />
{<br />
int n;<br />
while ((n = gzip.Read(buffer, 0, buffer.Length)) != 0)<br />
{<br />
outputFile.Write(buffer, 0, n);<br />
}<br />
}<br />
}<br />
}<br />
}<br />
Le Trung Hieu
|
|
|
|
|
What sort of data are you trying to compress? If it's something like an image file (Jpg, PNG, GIF, etc) then this data is already compressed, and a zip compression is unlikely to compress it further. The data ends up bigger since it has to add the zip header at the beginning of the output data.
|
|
|
|