|
Hi,
I have a problem, I want to check a data is entered to SQL database or not. I am making this in PHP like below:
<br />
$sql_name_check = mysql_query("SELECT name FROM names WHERE name='$buffer_name'");<br />
if(!mysql_num_rows($sql_name_check)){<br />
}<br />
So I want to do that in C# so I made a code block which is below:
<br />
int k=0;<br />
string buffer_name = "Cem Louis";<br />
SqlConnection mySqlConnection = new SqlConnection("Initial Catalog=names;Data Source=localhost;Integrated Security=SSPI;");<br />
SqlCommand mySqlCommand = mySqlConnection.CreateCommand();<br />
mySqlCommand.CommandText = "SELECT name, tel FROM names WHERE tel = '1' AND name = name";<br />
mySqlConnection.Open();<br />
SqlDataReader mySqlDataReader3 = mySqlCommand.ExecuteReader();<br />
while(mySqlDataReader3.Read())<br />
{<br />
k++;<br />
}<br />
if(k > 0)<br />
return false;<br />
else<br />
return true;<br />
mySqlDataReader3.Close();<br />
mySqlConnection.Close();<br />
Thank you;
Cem Louis...
|
|
|
|
|
|
And my question is:
How can I know that the SQL query returns a result? Is the cell filled with data??? The C# code that I wrote above is not doing this with variable k++ increment...
Thanks...
|
|
|
|
|
If you have any rows returned SqlDataReader has property HasRows
SO you can do:
if (reader.HasRows)
{
// something returned
}
|
|
|
|
|
hmm HasRows...
Thank you...
|
|
|
|
|
is there a way i can read a file that someone else has exclusive access to useing a streamreader
thanks
chad
|
|
|
|
|
No, not really. If they opened the file exclusively then it's opened, well, exclusively. It needs to be opened with FileShare.Read or some flag containing FileShare.Read in order for you to read it.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
the reson i am asking is because we have a csharp app that can read files while other users have the files exclusive and i would love to know how that programmer did it (its an app that we got from another company) and i know the files are exclusive because if i try to open then i get and error but this program dose not
thanks
chad
|
|
|
|
|
cmarmr wrote:
i would love to know how that programmer did it
One word: Reflector[^].
|
|
|
|
|
I need to detect when "windows + D" click or "show desktop" occurs. Which event occurs when this happenned?
karanba
|
|
|
|
|
The Windows message that is generated is not sent to every application, so you need to implement a Winodws hook. Read Using Hooks from C#[^] for more detail.
Specifically, you need to install a keyboard hook using WH_KEYBOARD (0x2). Your callback would be defined like so:
delegate IntPtr KeyboardProc(IntPtr code, IntPtr wParam, IntPtr lParam); The specific constants you want to check for are VK_LWIN (0x5b) and VK_RWIN (0x5c), as well as VK_D (0x44). Read KeyboardProc[^] for more information.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Is it a proper to design the business logic layer & Data access layer as a web service in a n-tier application. What are the pros and cons of using this. when should i use it and when i should not. My UI may be a windows or web application does webservice affect it by any way.
Another Query:
What the typical functions required in dblibrary.?
How can i optimize database access in a dblibrary?
What are the things to be kept in mind when designing a dblibrary?
How can i make my dblibrary also database independent i.e. tommorow i should be able to change the database without changing code just change the configuration settings in some resource file)?
I am sorry if its unclear .
Thanks to all who has answered my previous queries.
Thanks in advance for any reply?
I would like hear the answer of these queries with reason ie. why something is better or not?
with regards
anand
|
|
|
|
|
It is typically dependent on the client’s wish. Some clients do not prefer to business logic sitting on the IIS machine and for Web Services you require the IIS machine. In such situation, the solution is to use .NET remoting to access services secured inside the firewall while your IIS Web Service sits outside the firewall in the DMZ and just serves requests.
The question you have raised is really important from the point of view of the *trust* users are going to put over IIS/.NET basde Web Services, while the recent IIS exploit memories are still fresh. I expect some interesting advice from the Microsoft guys and the pattern gurus.
Your database questions are irrelevant for this forum, please use the ADO forum. Lets me tackle the only forum relevant question:
Database independent programming: OBBC technology has been around for years to solve this problem. .NET has OLEDB and ODBC Adaptors, which you can read on and use to achieve the same purpose. The documentation clearly stating which one among these two is suited for which purpose, is a bit rare to find, but some experts will soon throw light on this. Lets wait a while…
|
|
|
|
|
thanks, how to use .net remoting to access services in secure mode.
also let me know other ways of building web services.
Thanks again for the reply.
anand
|
|
|
|
|
If you are using Web Services, or using .NET Remoting over an HTTP channel, then simply buy yourself an SSL certificate from VeriSign[^], Thawte[^], or some other company and install it on IIS. These companies will have instructions, and please don't ask here because it's not a C#-related question.
If you want more granularity with what in your body gets encrypted, read about the Microsoft Web Service Enhancements[^], and implementation of industry standard specifications to encrypt, sign, route, and do more with SOAP (what Web Services use, and what .NET Remoting can use for a formatting channel).
If you want more information about how to build Web Services, I recommend you read some of the many articles on this site, or visit http://msdn.microsoft.com/webservices[^]. There is a lot of information available so this is not really a suitable subject for the forum, which is geared more toward specific questions.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi,
I have a webform, which changes the cssclass of a textbox and displays and error marker if the fields were left blank, or wrong data inputted etc.
For the reset button I would like to rack through the textboxes images within the form, and if the image is visible, turn it off etc.
I could do this by hard coding each instance of the image, but was hoping there would be a tidier way of doing this.
Here is what i have got already ...
foreach(object myControl in Page.Controls)
{
if(myControl is System.Web.UI.WebControls.Image)
{
System.Web.UI.WebControls.Image errImage = (System.Web.UI.WebControls.Image)myControl;
if(errImage.Visible == true)
{
errImage.Visible = false;
}
}
However all i am getting is the Html form itself and 2 literals.
I know im missing someting silly, but not sure what.
Any help would be appreciated.
Thanks
I first realised I was dyslexic when I went to a Toga party dressed as a goat.
|
|
|
|
|
hi,
Try this,
foreach(Control ctl in page.Controls)
{
Image Img= ctl as WebControls.Image;
if(Img!=null)
{
//do your operations
}
}
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
I am sorry if i am wrong how can i know that its a Image control or image in a datagrid or some thing else.
anand
|
|
|
|
|
Hi S r e e j i t h N a i r
Thanks but that didnt work either, I still only get the literals and the actual html form.
I first knew I was dyslexic when I went to a Toga party as a goat.
|
|
|
|
|
hello everybody
i am facing a problem to get the mouse position from the non client area in C#
i am using this technique but it is not working
protected override void WndProc(ref Message m)
{
if(m.Msg == 0xA0 ) //mouse move on NC area
{
try
{
Point pt = new Point();
Type t = pt.GetType();
pt = (Point)m.GetLParam(t);//pt = (Point)m.GetLParam(typeof(t)));
label1.Text = pt.X.ToString();
label2.Text = pt.Y.ToString();
}
catch(Exception e){Console.WriteLine(e);}
}
}
please help me
thanx
|
|
|
|
|
Use the static Position property of Cursor class to retrieve the mouse position.
Or what exactly isn't working?
www.troschuetz.de
|
|
|
|
|
i don't understand please clear how can i pass Cursor to get the mouse position if u have some example pls give it to me
thanx for ur reply
|
|
|
|
|
You don't need to pass anything. As the Position property is static, it can easily be accessed without having an instance.
protected override void WndProc(ref Message m)
{
if(m.Msg == 0xA0 )
{
Point pt = System.Windows.Forms.Cursor.Position;
label1.Text = pt.X.ToString();
label2.Text = pt.Y.ToString();
}
www.troschuetz.de
|
|
|
|
|
Point pt = System.Windows.Forms.Cursor.Position;
it maps the mouse position with respect to the desktop window not with respect to my app. to get the mouse position for my app i must calculate these coordinates with respect to my app position for geting the right mouse position am i right or do u have any idea.
than u very much
|
|
|
|
|
You're rigth. The Position property returns the mouse position in screen coordinates. The get them in client coordinates simply use the PointToClient method of your form.
<br />
Point ptScreen = Cursor.Position;<br />
Point ptClient = PointToClient(pt);
www.troschuetz.de
|
|
|
|