|
well, I'm not sure, I just added a DB in my project, created some tables, and now trying to reach those tables as
SqlConnection conn = null;
conn = new SqlConnection("Data Source=|DataDirectory|\\MyDatabase.sfd");
conn.Open(); <---- this is where the error points
|
|
|
|
|
Is the server running? Check all the services. Check if the user id and password you are providing has access to the database.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
I looked up the connection string from the app.config file and it did not have any connection parameters like id or password
"Data Source=|DataDirectory|\\MyDatabase.sfd"
I'm also not sure how to check these related services, as I explained to Covean, I added a DB to my project and I think it must have been running by default
:/
|
|
|
|
|
Maybe this article helps: http://support.microsoft.com/default.aspx?scid=kb;EN-US;914277
|
|
|
|
|
Use a SQLCeConnection [^] instead of a SQLConnection . You're connecting to a SQL CE database (*.sdf), not a SQL Server database (*.mdb). The latter one indeed requires a server
I are Troll
|
|
|
|
|
oh this might be the solution
YES IT IS!
THANK YOU!
and thanks to all others tried to help me
|
|
|
|
|
You're welcome
|
|
|
|
|
I am trying to host WCF web-service on GoDaddy.com, where I have web-site hosted in A-virtual directory and web-service hosted in B-virtual directory. Now, I am trying to access the files available in A-virtual directory from web service that is hosted on B-virtual directory and it gives me access denied error. But, If I copy the same files in B-virtual directory, I am able to access those files from web-service.
Now the question is, it's GoDaddy that is restricting this?? Can I solve this problem through code? If Yes, How? Or Do I need to contact GoDaddy to do it?? Or Do I need to purchase different kind of hosting account??
Thanks in advance.
|
|
|
|
|
|
Thanks for redirecting me to correct forum.
|
|
|
|
|
Hello
Can someone tell me how i can determine which element the mouse is hovering over on a page in a WebBrowser control?
So i want to do something like firebug element analyzer or ie select element by click.
Any thoughts on this?
Thanks
|
|
|
|
|
tanton-gaston wrote: Any thoughts on this?
Yep.
You should post this in the Web Development Forum!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
DataTable dt;
private void Permissions_Load(object sender, EventArgs e){
dt = new DataTable();
dt.Columns.Add("Feature", typeof(string));
dt.Columns.Add("None", typeof(bool));
dt.Columns.Add("ReadOnly", typeof(bool));
dt.Columns.Add("ReadWrite", typeof(bool));
datagridview1.Datasource=dt;
}
private void btnSave_Click(object sender, EventArgs e){
}
public void SetPermission(Permission feature, PermissionType permission, int userID) {
SqlCommand cmd = new SqlCommand("Insert into Permissions (UserID,Feature,Permission)Values(@UserID,@Feature,@Permission)", con);
cmd.Parameters.Add(new SqlParameter("UserID", userID));
}
public enum Permission : int
{
Country = 0,
Store = 1,
City = 2
}
public enum PermissionType : byte
{
None = 0,
ReadOnly = 1,
ReadWrite = 2
}
C# Developer
modified on Tuesday, October 27, 2009 8:21 AM
|
|
|
|
|
What happenned to your windows forum thread? Why not continue there?
|
|
|
|
|
|
This post looks like continuation of your post yesterday in the Windows forms forum. It is still top most over there.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
probably there are small numbers of users
ok and can you answer me?
C# Developer
|
|
|
|
|
How to plug/unplug USB serial port problematically?
I am facing some strange issue with my USB serial port.
I want to unplug and plug the USB Serial port Programitically, as i need to refresh the connection between system and hardware connected.Kindly help.......
Thank in advance for the great programmers
|
|
|
|
|
...
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
I agree that i cross post, but the reason behind is, i am not particular about the language used for my problem.I am only looking for the solution and it will be great if you have anything let me know.
|
|
|
|
|
Still not a reason to spam the forums as you have
only two letters away from being an asset
|
|
|
|
|
try this using devcon.exe . Its get from
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q311272
Run this exe using process class ... have lot of commanding is there.. i thing its useful for u
Thank u
|
|
|
|
|
If i used crystal report in my project login failed error is has been generated.The error asking for username and password but i am not given any username and password to sql server.It is not giving me problem when i am doing my insert update queries. It is only shows error when i use crystal report . Is their any external connection for crystal report.Please give me solution urgently.
|
|
|
|
|
Hello,
First of all thanks for reading this. I am aiming to create a proxy server to overcome some authentication problems. The idea is to have the server handling the requests to a certain port, appending the right credentials, sending the authenticated request to the desirable address, and giving back the response (bytes) to the client.
For that I created two sockets: a listening socket and a client socket for which I show here, the class definition.
As I have a large volume of information on the requests, I am trying to use asynchronous sockets, so that I wont block the system waiting for an answer.
The RequestState class contains the definitions for the state of the request, including a buffer.
The process results in a serious of callbacks and the order of events is more or less this: the BeginGetResponse calls the RespCallback, where the webrequest to the desirable page is thrown, and it activates the BeginRead, that calls a ReadCallback. The readCallback fills the buffer and then I can either call a synchronous blocking send request (which does not work on IE, for e.g.) or call BeginSend with a callback function. The BeginSend also does not work, since the callback (finish) terminates without actualy sending all the information.
Any tips about what I'm doing wrong?
Thanks in advance,
Jo
using System;
using System.Net;
using System.IO;
using System.Net.Security;
using System.Net.Sockets;
using System.Threading;
using System.Text;
namespace TEST
{
public class RequestState
{
public int BufferSize = 1024;
public byte[] RequestData;
public byte[] BufferRead;
public WebRequest Request;
public Stream ResponseStream;
public WebResponse Response;
public Socket aSocket;
public RequestState()
{
BufferRead = new byte[BufferSize];
RequestData = new byte[0];
Request = null;
aSocket = null;
ResponseStream = null;
}
}
public delegate void DestroyDelegate_(ProxyClient client);
public class ProxyClient : IDisposable
{
const string myUri="http://DEV309.Dev.cadcorp.net:4326/KmlService/Kml.serv?REQUEST=GetCapabilities";
public ProxyClient(Socket ClientSocket, DestroyDelegate_ Destroyer, IPEndPoint MapTo, CredentialCache credCache)
{
this.ClientSocket = ClientSocket;
this.Destroyer = Destroyer;
this.MapTo = MapTo;
this.m_credCache = credCache;
this.m_sendDone = new ManualResetEvent(true);
}
private IPEndPoint MapTo
{
get
{
return m_MapTo;
}
set
{
if (value == null)
throw new ArgumentNullException();
m_MapTo = value;
}
}
internal Socket ClientSocket
{
get
{
return m_ClientSocket;
}
set
{
if (m_ClientSocket != null)
m_ClientSocket.Close();
m_ClientSocket = value;
}
}
public void Dispose()
{
try
{
ClientSocket.Shutdown(SocketShutdown.Both);
}
catch { }
if (ClientSocket != null)
ClientSocket.Close();
ClientSocket = null;
if (Destroyer != null)
Destroyer(this);
}
private void ReadCallBack(IAsyncResult asyncResult)
{
try
{
RequestState myRequestState = (RequestState)asyncResult.AsyncState;
Stream responseStream = myRequestState.ResponseStream;
int read = responseStream.EndRead(asyncResult);
if (read > 0)
{
byte[] newBuffer = new byte[myRequestState.RequestData.Length + read];
Buffer.BlockCopy(myRequestState.RequestData, 0, newBuffer, 0, myRequestState.RequestData.Length);
Buffer.BlockCopy(myRequestState.BufferRead, 0, newBuffer, myRequestState.RequestData.Length, read);
myRequestState.RequestData = newBuffer;
IAsyncResult asynchronousResult =
responseStream.BeginRead(myRequestState.BufferRead, 0, myRequestState.BufferSize,
new AsyncCallback(ReadCallBack), myRequestState);
}
else
{
if (myRequestState.RequestData.Length > 0)
{
myRequestState.aSocket.BeginSend(myRequestState.RequestData, 0, myRequestState.RequestData.Length,SocketFlags.None, new AsyncCallback(Finish), myRequestState);
}
}
}
catch (SocketException ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
Dispose();
}
}
private void Finish(IAsyncResult asyncResult)
{
try
{
RequestState myRequestState = (RequestState)asyncResult.AsyncState;
Socket mySocket = myRequestState.aSocket;
int Ret = mySocket.EndSend(asyncResult);
if (Ret <= 0)
{
Dispose();
myRequestState.ResponseStream.Close();
}
}
catch (SocketException ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
Dispose();
}
}
private void RespCallback(IAsyncResult asynchronousResult)
{
try
{
RequestState myRequestState = (RequestState)asynchronousResult.AsyncState;
WebRequest myWebRequest1 = myRequestState.Request;
myRequestState.Response = myWebRequest1.EndGetResponse(asynchronousResult);
Stream responseStream = myRequestState.Response.GetResponseStream();
myRequestState.ResponseStream = responseStream;
IAsyncResult asynchronousResultRead =
responseStream.BeginRead(myRequestState.BufferRead, 0, myRequestState.BufferSize,
new AsyncCallback(ReadCallBack), myRequestState);
}
catch (SocketException ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
Dispose();
}
}
public void StartHandshake()
{
try
{
WebRequest request = (HttpWebRequest)WebRequest.Create(myUri);
request.Credentials = m_credCache;
RequestState myRequestState = new RequestState();
myRequestState.Request = request;
myRequestState.aSocket = ClientSocket;
IAsyncResult r = (IAsyncResult)request.BeginGetResponse(
new AsyncCallback(RespCallback), myRequestState);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.ToString());
Dispose();
}
}
private CredentialCache m_credCache;
private DestroyDelegate_ Destroyer;
private Socket m_ClientSocket;
private IPEndPoint m_MapTo;
private ManualResetEvent m_sendDone;
}
|
|
|
|
|
I didn't debug the code, but I see you used a lot of async calls. Do you really need that much of async calls?
I will explain: If I am not wrong, every async call will use a ThreadPool thread. So, on the first callback you will be in a thread-pool thread (instead of the main one). Generating a new async callback will only use a new Thread to do the parallel work, for something that is already in parallel.
So, maybe you can simplify everything simple doing everything "sinchronously" inside a ThreadPool thread, by using a ThreadPool.QueueUserWorkItem. I think this way the code will get more readable, you will make it work and also will be faster, as it will use only one thread instead of 3 or 4 threads to finish the work.
Also, for the read (not the write) note that you may ask to read 100 bytes and the read can read 3 bytes and return 3. This way, if you REALLY need that 100 bytes, you will need to call read again, as many times as needed or even throw an exception if the connection is closed before it finishes.
|
|
|
|
|