|
Erm. AFAIK the whole point of a parameterized query was to stop this kind of design so that's not going to work.
You'd have to go back to the old skool method of generating the entire SQL statement and firing it back to your DB. I'd check if you really need to as this is horrendously insecure. Can you just not create a search stored proc and pass in a search term on that?
|
|
|
|
|
Thanks,
I'll look at doing it through the stored procedure as you mentioned.
|
|
|
|
|
It depends on the type of database you are using as to how you tackle this, but you could add a temporary table that you use to add the individual parsed out elements in as individual elements, and then perform your main query using that table as a linked table, so you'd end up with SQL along the lines of:
SELECT ... FROM MyTable INNER JOIN MyTemporaryTable ON MyTable.Code = MyTemporaryTable.Code Also, rather than having them enter the codes, why not display them in a list that they can select from? This way you save them having to remember potentially archane code sequences.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Something like cmd.Parameters [ "@CodeVal" ].Value = tbCode.Text ; ?
|
|
|
|
|
|
Apart from being wide open to a SQL injection attack, this just won't work because it only applies to 1 value.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hello guys...
I am building a c# app to detect the internet connection and then send sms to a person regarding the status. I've got the codes with me but i wrote them as individual modules. I need to integrate them. any help????????? And by the way its a c# windows app...
|
|
|
|
|
S.Bharath Ram wrote: I've got the codes with me but i wrote them as individual modules.
What makes a difference if it is individual module or one single module, if the functionality of the application is as simple as you describe it.
S.Bharath Ram wrote: I need to integrate them.
integrate what? the difference modules? Well, if you know how to write the modules, you will know how to integrate them
|
|
|
|
|
Keep the question as brief as possible. Provide more information whatever you have written.
|
|
|
|
|
S.Bharath Ram wrote: individual modules. I need to integrate them
This is easy. The other way round is what most people struggle with.
|
|
|
|
|
5'd.
ragnaroknrol The Internet is For Porn[^]
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
|
|
|
|
|
+5 to correct the univote.
|
|
|
|
|
Edit : I have tried Dictionary<string[,], Texture2D> _lookup but doesnt work
In xna I want to create a texture2D factory class so that I can grab preloaded textures on the fly without having to load them repeatedly.
I want something like
paddleTexture = GetData<Texture2D>(string foldername,string assetname)
for example:
GetData<Texture2D>("Sprite","paddle");
But I am having generic Dictionary troubles
I just cant seem to create its structure properly !
I have tried Dictionary<string ,Dictionary<string,Texture2D>> which is not what I want at all and I also load the data via a simple XML file:
<?xml version="1.0" encoding="utf-8"?>
<FileSystem>
<Folder Name="Sprite" Location = "Image/2D/Sprite">
<Texture Name ="paddle"></Texture>
<Texture Name ="ball"></Texture>
</Folder>
</FileSystem>
Can anyone help me with the structure of the generic Dictionary?
Thanks !
-- Modified Wednesday, August 4, 2010 7:51 PM
|
|
|
|
|
Just solved it Dictionary<string, int=""> and simply joined the folder and asset name into one string for the primary key
ie: lookup.Add(folder + assetname,texture);
|
|
|
|
|
I've been working on this one for two days, and I DON'T think it's a memory or disk-space problem.
I have a C# image-processing application that uses Win32 to do the graphics for speed. I restructured it so that different threads could work on different images in parallel (so far with just one thread), and got the above error message.
The Google entries for this problem all assume there are memory/disk space limitations, but I know this isn't the problem because the old (non-threaded) version runs fine, and Process Explorer tells me the threaded version isn't using any more memory.
Has anyone seen this error message before? Any suggestions what to look for to track down the cause of this error?
Thanks,
Alan
|
|
|
|
|
Have you seen this blog[^]. Could it help in your situation?
|
|
|
|
|
The cause of the problem is that apparently Win32 bitmap handles become STALE, i.e. they're for temporary use only.
This led to the problem showing up in different places, depending on when Windoze decided to make the handles invalid.
The solution was to pass bitmaps into the lower-level C# functions, then obtain the handles at the last possible moment, inside a loop, just before descending into Win32. These handles were fresh for each iteration, and worked perfectly.
I think the Win32 system should provide a less-misleading error message when a stale handle has been used. &*($! Microsoft!
|
|
|
|
|
OK i have made a DLL with only one accessible function. It returns a panel with a label in it.
In the dll there's also an event handler for mousemouve. It needs to change the label to display the mouse position on the panel.
My problem is that i need everything done on the side of the DLL. The main program is only there to place the panel on a form and must not deal with event handling from the panel.
here's what i got for the dll
namespace PanelClass
{
public class ConstPanel
{
public Panel FabPan(int x, int y)
{
Panel P = new Panel();
Label L = new Label();
L.Left = 1;
L.Top = 1;
L.Text = "allo";
P.Height = y;
P.Width = x;
P.BorderStyle = BorderStyle.FixedSingle;
P.Controls.Add(L);
P.MouseMove += new MouseEventHandler(P_MouseMove);
return P;
}
void P_MouseMove(object sender, MouseEventArgs e)
{
//needs to change the text in label L
}
}
}
and the main application
private void button1_Click(object sender, EventArgs e)
{
PanelClass.ConstPanel P = new ConstPanel();
Panel Pan = P.FabPan(100, 100,1);
this.Controls.Add(Pan);
}
So what should i do
thanks for your time
modified on Thursday, August 5, 2010 8:41 AM
|
|
|
|
|
Hi,
1.
this should not be a problem at all; you need to pass the label reference from FabPan() to P_MouseMove(). The easiest way to do that is by turning L into a class member instead of a local variable.
2.
please use PRE tags (e.g. through the "code block" widget) to publish multi-line code snippets. The result is much more readable.
3.
I'm pretty sure your code does not compile as it is. Here are some reasons:
- there seems to be something wrong with the parameter list of PanFab().
- I don't think you can set a BorderStyle for a Panel.
4.
I have lots of comments on your coding style; frankly it is horrible. Here are some points that you should fix:
- having "class", "object" and many more as part of an identifier/name isn't a good idea, as it is either redundant or confusing (e.g. your PanelClass isn't a class, it's a namespace!)
- you should choose better variable names in general, e.g. having both Pan and P is confusing (and local variables by convention aren't TitleCased in C#)
- you should consider making ConstPanel inherit from Panel, and putting everything FabPan does into the constructor. You could still pass parameters to the constructor, however there are some advantages not doing that, besides a Panel has standard properties such as Size, Width, Height, and many more. So I suggest something like:
public class ConstPanel : Panel {
private Label label;
public ConstPanel() {
label = new Label();
label.Left = 1;
label.Top = 1;
label.Text = "allo";
...
That way, the button click handler would become:
Height) are public properties; you could turn it into:
private void button1_Click(object sender, EventArgs e) {
ConstPanel panel = new ConstPanel();
panel.Size=new Size(100,100);
this.Controls.Add(panel);
}
As it seems you are very new to all this, I strongly suggest you buy an introductory book on C# and study it. Experimentation is useful, having a book providing solid fundamentals is essential.
|
|
|
|
|
I need to split string "abcdef" in 2 groups - first will contain first 4 characters, second - remaining 2.
If I use this:
string[] w = Regex.Split("abcdef", "(?<first>.{4})(?<last>.{2})");
array w[] will contain 4 strings: "", "abcd", "ef", ""
How should I modify pattern so that w[] only contains 2 strings - "abcd" and "ef"?
|
|
|
|
|
You would use substring and not regex.
|
|
|
|
|
I know how to use substring for this. Is this not possible to achieve using regex?
|
|
|
|
|
Does it have to use the split method of Regex or can it use any regex methods? You can downgrade to the 1.0 or 1.1 Framework since those parsed it that way.
If you want to drive a nail using a banana that's fine, but if you ask for help in doing so, don't be surprised if the answer is either "don't do that" or "go ask a monkey".
|
|
|
|
|
Why would you use a regex for this? Why not just use a substring? How is it supposed to act for strings that aren't 6 characters exactly?
|
|
|
|
|
Actual goal is to split fixed-width string that consists of multiple fields (dozens of them). Fields are not delimited by any separator but defined by their positions in the string - first field occupies first 4 characters, second - next 2 characters, etc. Using regex allows to do this with one function call. As you can see I almost achieved what I am looking for - I just want to get rid of first and last string in the array that are empty. Yes, I can just ignore them in my code but I would like to know correct regex expression.
|
|
|
|