|
The Select method of the DataTable class allows you to do just that, using pseudo T-SQL.
It returns an array of DataRow .
E.g.:
DataRow[] results = yourDataTable.Select("aa=15");
var question = (_2b || !(_2b));
|
|
|
|
|
Thanks for replying..
Greg Chelstowski wrote: DataRow[] results = yourDataTable.Select("aa=15");
I have to check it at runtime, and there is no static value as written by you in query. the datatable can have any number of both numeric, alphanumeric records.
Please suggest something.
|
|
|
|
|
abcurl wrote:
I have to check it at runtime
???
abcurl wrote: and there is no static value as written by you in query
Then use variables. And by static I'm sure you meant hard-coded.
abcurl wrote: the datatable can have any number of both numeric, alphanumeric records.
Use single quotes in the query then!
Now, once you actually got your DataRow array, I'm sure you'll be asking next how to extract values from it. Look, do some reading on MSDN, there are a million tutorials and examples on the .Select method of DataTable.
var question = (_2b || !(_2b));
|
|
|
|
|
If possible try to use the Regex. May be it helps solving your problem.
|
|
|
|
|
I use below code for add picture to dataBase but if I need that insert null instead of picture into database the program give me Error (I set allowNull for column in Sql)
(it's neccesary becuase maybe user dosen't have picture for insert into database)
how can I do that?
MemoryStream mstr = new MemoryStream();
pictureBox1.Image.Save(mstr, pictureBox1.Image.RawFormat);
byte[]pic= mstr.GetBuffer();
SqlConnection sq=new SqlConnection(...);
SqlParameter sp1 = new SqlParameter("@pic", pic);
SqlCommand sc = new SqlCommand("insert into Info values(@pic)", sq);
sc.Parameters.Add(sp1);
sc.ExecuteNonQuery();
|
|
|
|
|
Hi,
could you post the error you receive (message etc.)? Maybe your db-schema doesn't allow null-values for the picture column.
Regards
Sebastian
|
|
|
|
|
I set allowNull for that column
|
|
|
|
|
And the error you receive is?
|
|
|
|
|
Error : parameter @pic, which was not supplied
|
|
|
|
|
Try to pass
<br />
System.DBNull.Value<br />
as parameter value when pic1 is null.
|
|
|
|
|
Error : Operand type clash: nvarchar is incompatible with image
|
|
|
|
|
There's your problem right there. nvarchar is a text based field, and you are trying to store an image in it - you need to change the column type in the database, or save the image to disk and store the location of the image in this field.
"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
|
|
|
|
|
hi, try the following code, it may help you.
int len = Upload.PostedFile.ContentLength;
byte[] pic = new byte[len];
Upload.PostedFile.InputStream.Read (pic, 0, len);
SqlConnection sq=new SqlConnection(...);
SqlCommand cmd = new SqlCommand ("insert into values(@pic)", sq);
cmd.Parameters.Add ("@pic", pic);
cmd.ExecuteNonQuery ();
modified 27-May-14 4:59am.
|
|
|
|
|
hi, try the following code, it may help you.
int len = Upload.PostedFile.ContentLength;
byte[] pic = new byte[len];
Upload.PostedFile.InputStream.Read (pic, 0, len);
SqlConnection sq=new SqlConnection(...);
SqlCommand cmd = new SqlCommand ("insert into values(@pic)", sq);
cmd.Parameters.Add ("@pic", pic);
cmd.ExecuteNonQuery ();
April
Comm100 - Leading Live Chat Software Provider
modified 27-May-14 9:00am.
|
|
|
|
|
How can I use DataBase without attach ?
I want to write a program and use sql how can I Insert,... data to sql without attach database file ?
|
|
|
|
|
Hi,
what do you mean by 'attach'?
Regards
Sebastian
|
|
|
|
|
attach means not attaching dB file just put It in program's directory and use it like SQLEXPRESS
|
|
|
|
|
So you want to use the db file (sql-express) without attaching it to the server? Well I think this is not possible. But you could use another database like derby etc. which can be used without an existing server...
|
|
|
|
|
Simple. You can't. In order to use a database file it must be attached.
Bob
Ashfield Consultants Ltd
Proud to be a Code Project MVP
|
|
|
|
|
Dear all,
I am trying to access a xml configuration file from windows service. But it
is failing. configuration file is in the same directory from where I install
windows service. I dont want to give an absolute path to the location of
file. When I try to start windows service, it is expecting the XML file to
be in c:\windows\system32\.
Please let me know whether there is a way to access xml files from windows
service.
Thanks.
|
|
|
|
|
Hi,
you will need the absolute path to the file within your windows service if you don't want to copy the file to the windows-folder. Use the registry as a configuration for your service, write the registry value while installing and read the value within the service.
Regards
Sebastian
|
|
|
|
|
Do you mean the standard app.config? If so, it is expected to be in the same folder as your exe. In any other case its up to you to tell the service where to look, generally by an entry in the app.config.
Bob
Ashfield Consultants Ltd
Proud to be a Code Project MVP
|
|
|
|
|
You can determine the path to your service by looking for the ImagePath value in the registry.
object objImgPath = Registry.GetValue("HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\[name of your service]", "ImagePath", null); ;
Be sure you have the rights to access this registry key (but a service should have this rights).
Greetings
Covean
|
|
|
|
|
Hello,
I need some help in order to solve a little,annoying problem-flickering.
I've built a Drawer, that works perfectly , but flickers alot,
the general idea is inserting each shape that the user wants to Draw into
a Drawing list and Draw the whole list in paint event each time.
In the last few days ,i've been reading articles about how to solve it,
I tried setting DoubleBuffer to true but it doesn't help at all.
I've seen some methods to stop the flicker in this web but i cant understand/use them.
I need something as simple as possible that of course works.
(c#, using System.Drawing.Drawing2D; creategraphics(); method
Thank you very much.
|
|
|
|
|
I've had similar problems in the past. I seem to remember that the only way that I was able to stop the flicker was to implement manual double buffering. See the article here[^] to see how to do this (and to first verify that your settings are correct to automatically double buffer the image prior to putting in a bunch of wasted effort).
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|