|
why do you use "http://domainname.com//dbChartImager.mdb";
why not "http://domainname.com/dbChartImager.mdb"; ?? ![Sleepy | :zzz:](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_snore.gif)
|
|
|
|
|
The error you're getting is telling you it's NOT correct.
And it's rigt - you cannot access an Access database over HTTP. Access is a file-based database and you haven't provided a filesystem based path to the database.
|
|
|
|
|
if i could not access it using http then how i can access it.
Actually my idea is to place my database on a center point on some where hosting server that every user can access it through internet(not local network). every machine where my desktop application will install will be connect to this database for login verification.
if i could not access it through http then what will be the pay to access it? can you please some sample code in which i can access it.
say my database is on http://domainname.com/dbChartImager.mdb
then how i can get it execute a query?
|
|
|
|
|
sher_azam wrote: Actually my idea is to place my database on a center point on some where hosting server that every user can access it through internet(not local network
Through the Internet, you cannot use an Access database directly. You have to go through some webserver that does the database access for your application. Your app can talk to the webservice over HTTP.
|
|
|
|
|
Member 4624055 wrote: string strDBPath ="http://domainname.com//dbChartImager.mdb";
You cannot connect to an Access database over HTTP like this.
What are you trying to accomplish here? Is the idea that people will be able to run the application remotely, connecting to the central database via an internet connection? Or are all the users running on the same local network, i.e. sharing the same central database, but not over the internet?
|
|
|
|
|
Actually my idea is to place my database on a center point on some where hosting server that every user can access it through internet(not local network). every machine where my desktop application will install will be connect to this database for login verification.
if i could not access it through http then what will be the pay to access it? can you please some sample code in which i can access it.
say my database is on http://domainname.com/dbChartImager.mdb
then how i can get it execute a query?
|
|
|
|
|
As some people here pointed out, the "database" of your choice doesn't support access over http so my suggestion is to have a web service which all clients connect to and then user name and password can be validated against your database. Good luck!
|
|
|
|
|
Thanks Calla,
i think web service is the best solution for this. i will go for it. thank you so much for you all my friends.
|
|
|
|
|
You're welcome
A webservice also gives you the advantage of being able to change your business layer (maybe your database change layout or you switch databases) without having to change anything in any of the clients. So from an architectural point of view this is also a better and more flexible solution.
|
|
|
|
|
I've followed the following tutorial: http://msdn.microsoft.com/en-us/library/system.net.security.negotiatestream%28VS.80%29.aspx[^]
and have implemented a server and client application.
When I use the client to connect to the server on the same machine (i.e. the IP is 127.0.0.1) it makes a secure connection.
When I use the client on my XP machine to connect to the server on my Vista machine then the line:
authStream.EndAuthenticateAsServer(ar);
fails with the exception I pasted into the subject of this post.
What I want to do is allow any client on any machine over the internet or LAN to connect to my server on port 9000 over an encrypted connection.
I would be happy if I could allow the client to specify a username and password - but I don't know how to implement that functionality.
details on the exception:
$exception
- $exception {"The server has rejected the client credentials."} System.Exception {System.Security.Authentication.InvalidCredentialException}
+ [System.Security.Authentication.InvalidCredentialException] {"The server has rejected the client credentials."} System.Security.Authentication.InvalidCredentialException
+ Data {System.Collections.ListDictionaryInternal} System.Collections.IDictionary {System.Collections.ListDictionaryInternal}
HelpLink null string
+ InnerException {"The logon attempt failed"} System.Exception {System.ComponentModel.Win32Exception}
Message "The server has rejected the client credentials." string
Source "System" string
StackTrace " at System.Net.Security.NegoState.EndProcessAuthentication(IAsyncResult result)\r\n at System.Net.Security.NegotiateStream.EndAuthenticateAsServer(IAsyncResult asyncResult)\r\n at RemoteDiagnostics.Server.class_RDServer.EndAuthenticateCallback(IAsyncResult ar) in C:\\Users\\Nuclear\\Documents\\Visual Studio 2008\\Projects\\RemoteDiagnostics\\RemoteDiagnostics\\Server\\class_RDServer.cs:line 280" string
+ TargetSite {Void EndProcessAuthentication(System.IAsyncResult)} System.Reflection.MethodBase {System.Reflection.RuntimeMethodInfo}
authStream
- authStream {System.Net.Security.NegotiateStream} System.Net.Security.NegotiateStream
+ base {System.Net.Security.NegotiateStream} System.Net.Security.AuthenticatedStream {System.Net.Security.NegotiateStream}
CanRead false bool
CanSeek false bool
CanTimeout true bool
CanWrite false bool
+ ImpersonationLevel 'authStream.ImpersonationLevel' threw an exception of type 'System.Security.Authentication.InvalidCredentialException' System.Security.Principal.TokenImpersonationLevel {System.Security.Authentication.InvalidCredentialException}
IsAuthenticated false bool
IsEncrypted false bool
IsMutuallyAuthenticated false bool
IsServer true bool
IsSigned false bool
+ Length 'authStream.Length' threw an exception of type 'System.NotSupportedException' long {System.NotSupportedException}
+ Position 'authStream.Position' threw an exception of type 'System.NotSupportedException' long {System.NotSupportedException}
ReadTimeout -1 int
+ RemoteIdentity 'authStream.RemoteIdentity' threw an exception of type 'System.Security.Authentication.InvalidCredentialException' System.Security.Principal.IIdentity {System.Security.Authentication.InvalidCredentialException}
WriteTimeout -1 int
|
|
|
|
|
I found an example where the client specifies credentials:
http://msdn.microsoft.com/en-us/library/system.net.security.protectionlevel.aspx[^]
but I'm not happy that the client needs to know the username and password of the machine that the server is running on.
If I have to store username and password for various machines in my exe.config then that seems impractical.
I guess I will just go back to using TcpClient.Connect() and encrypting the data myself prior to transmission. ![Cry | :((](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_cry.gif)
|
|
|
|
|
Well there a few major errors occcuring in the following program:
1) line 18: usleep was not declared in the scope
2) line 14,15,23,..: stray'\160' in the program
3) Also i am getting an error in my process.h file. Can somebody tell where i can get this file. I got it from:
http://www.koders.com/c/fid1DB5A7F33E56F9DDD9AFDC7EF0F05CF767EA426A.aspx
Here is the program:
#include<stdio.h>
#include<windows.h>
#include<pthread.h>
#include<process.h>
#include<unistd.h>
#include<stdlib.h>
/* This is our thread function. It is like main(), but for a thread */
void *threadFunc(void *arg)
{
char *str;
int i = 0;
str=(char*)arg;
while(i < 10 )
{
usleep(1);
printf("threadFunc says: %s\n",str);
++i;
}
return NULL;
}
int main()
{
pthread_t pth;
int i = 0; // this is our thread identifier
/* Create worker thread */
pthread_create(&pth,NULL,threadFunc,"processing...");
/* wait for our thread to finish before continuing */
pthread_join(pth, NULL); // void ** return value could go here
while(i < 10 )
{
usleep(1);
printf("main() is running...\n");
++i;
}
return 0;
}
|
|
|
|
|
Maybe you ought to post this in the C++ forum instead of C# ![Wink | ;)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_wink.gif)
|
|
|
|
|
You could also try formatting your code properly (see the guidelines above) and clarifying exactly which lines your errors occur on, and whether these are compile or execution time errors.
|
|
|
|
|
I’ve using a Queue to store data and I do polling in order to know if the Queue contain data ( that I understand is not the correct approach)
For Example
private void PopDataFromQueue()
{
bool isRspOK;
byte [] data;
while (true)
{
//If so then stop the thread
if (m_isStopReadingQueueThread == true)
break;
if (m_queue.Count > 0)
{
lock (m_queue)
{
if (m_queue.Count > 0)
{
data = (byte [])m_queue.Dequeue();
isRspOK = m_scenario.Parse(sockBuf.SocketData);
if (isRspOK == true)
{
;
}
}
}
}
}
I need to implement approach that wait for event occur and not always check the Queue status
The function PopDataFromQueue is define as a thread
Something like this
private void PopDataFromQueue()
{
//create timer event that indicate in case the event that I waiting for not reach after some time , need to handle it
Timer timer = new timer(1000);
while (true)
{
//If so then stop the thread
if (m_isStopReadingQueueThread == true)
break;
Event = WaitForEvent(Queue.Add,Timer. expire); // need to wait for two type of events
Switch(Event)
{
case Queue.Dataexist:
data = (byte [])m_queue.Dequeue();
isRspOK = m_scenario.Parse(sockBuf.SocketData);
if (isRspOK == true)
{
;
}
Break;
Case timer.expire:
isStopReadingQueueThread =true;
break;
}
}
}
I try to look in the net and I didn’t found
Any advice?
Thanks
Ronen
|
|
|
|
|
you need to write your own queue that raises an event if data pushed or poped in/from queue.
|
|
|
|
|
you are correct by saying that the worker thread should be event-driven and should not poll...
I have used the following example to learn from:
Bounded Blocking Queue (One Lock)[^]
and within your worker thread (it must be a thread that is started in the constructor) use:
while (true)
{
lock (syncRoot)
{
while (iCount <= 0)
Monitor.Wait(syncRoot);
class_Message MessageWorker = messageQueue.Dequeue();
iCount--;
.
.
.
this has worked out really well and eventhough it's a blocking queue it works nice and fast !
|
|
|
|
|
I have come across something and wondered if it can be done.
private void Shape_CheckedChanged(object sender, EventArgs e)
{
if (rbDraw.Checked)
{
if (rbSelectShape.Checked)
{
imageViewer1.ShapeSelected = ImageViewer.Shape.Select;
}
if (rbDrawRect.Checked)
{
imageViewer1.ShapeSelected = ImageViewer.Shape.Rectangle;
}
if (rbDrawCircle.Checked)
{
imageViewer1.ShapeSelected = ImageViewer.Shape.Circle;
}
if (rbDrawTriangle.Checked)
{
imageViewer1.ShapeSelected = ImageViewer.Shape.Triangle;
}
if (rbLine.Checked)
{
imageViewer1.ShapeSelected = ImageViewer.Shape.Line;
}
if (rbText.Checked)
{
imageViewer1.ShapeSelected = ImageViewer.Shape.Text;
}
}
Console.WriteLine(imageViewer1.ShapeSelected.ToString());
}
Above is the code i used to check each radio button however i tried tidying it up with the bellow code and couldn't think of a way to set the enum depending on checked radio button.
foreach (RadioButton rb in gbShape)
{
if (rb.Checked == true)
{
imageViewer1.ShapeSelected = ImageViewer.Shape.Circle;
}
}
Any ideas
Thanx in advance
|
|
|
|
|
You can make use of Tag property of the radio buttons for this. While creating the buttons, set the Tag as enum value, like:
rbSelectShape.Tag = ImageViewer.Shape.Select;
Then in your foreach loop, use this:
imageViewer1.ShapeSelected = rb.Tag;
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Thank you for the response, that is a great idea and will make things shorter and easier to follow.
Can also do this for the other group boxes on the form.
Thanx George
|
|
|
|
|
In that case i would make a new class called ShapeRadioButton derived from RadioButton.
in that new derived class i would implement a Property called Shape..? from type of your enum.
using the tag would be a solution but i think my solution is not very difficult and would be better programming, think of it you want to use a second object than the tag object is used by you enum and the second gets what ?!? ^^ in the ShapeRadioButton you only need to implement the new property for the type and thats it.
greetz ![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
I don't think i fully understand how that would work.
class ShapeRadioButton : System.Windows.Forms.RadioButton
{
private ImageViewer.Shape m_shape = ImageViewer.Shape.Select;
public ImageViewer.Shape Shape
{
get
{
return m_shape;
}
set
{
m_shape = value;
}
}
}
i made the class ^ however it still needs to be set somewhere> do you mean the designer will set each RadioButton to have an instance of "ShapeRadioButton". Then use it in the same way as the tag
Thax George
|
|
|
|
|
I have tried this solution however the following error occurs which i do not understand
Error 1 foreach statement cannot operate on variables of type
'System.Windows.Forms.GroupBox' because 'System.Windows.Forms.GroupBox'
does not contain a public definition for 'GetEnumerator'
The code is as follows:
if (rbDraw.Checked == true)
{
foreach (RadioButton rb in gbShape)
{
if (rb.Checked == true)
{
imageViewer1.ShapeSelected = (FileScroller.ImageViewer.Shape)rb.Tag;
}
}
}
|
|
|
|
|
ok use
if (rbDraw.Checked == true)
{
foreach (Control ctrl in in gbShape.Controls)
{
if (ctrl is RadioButton)
{
if (rb.Checked == true)
{
imageViewer1.ShapeSelected = (FileScroller.ImageViewer.Shape)rb.Tag;
}
}
}
}
your RadioButtonClass:
public class ShapeRadioButton : System.Windows.Form.RadioButton
{
private FileScroller.ImageViewer.Shape _shape;
public FileScroller.ImageViewer.Shape Shape{
get{return _shape;}
set{_shape = value;}
}
|
|
|
|
|
That should work only problem being the rb doesnt exsit anymore and ctrl will not allow:
if (ctrl.Checked == true)
|
|
|
|