|
Well, your connection string should look like this (from connectionstrings.com):
Server=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Trusted_Connection=False;
So, add a new string property to the class and construct that string using what you have. That's what you want for ?????????.
eg:
public string ConnectionString
{
get
{
return string.Format("Server={0};Database={1};User ID={2};Password={3};Trusted_Connection={4};", SqlServer, Database, User, Password, Trusted ? "True" : "False");
}
}
Regards,
Rob Philpott.
|
|
|
|
|
Hi Rob,
Thanks very much.Can we connect to the database with out using the connection string?
Just with the class you have given me? Can you give me just an example.
Sorry i am taking you time.
Thanks Rob
|
|
|
|
|
Yeah, you could add some functionality to that class which returns a valid open connection, and just use that as the connection
Something like:
public SqlConnection CreateConnection()
{
SqlConnection connnection = new SqlConnection(ConnectionString);
connection.Open();
return connection;
}
Remember to use the connection in a using bloke or call its dispose when you are done with it.
Regards,
Rob Philpott.
|
|
|
|
|
Do you think this should work to execute a stored procedure.
SqlDataAdapter sda = new SqlDataAdapter("Stored_proce", DatabaseConfiguration.connectionstring);
or simply use
SqlDataAdapter sda = new SqlDataAdapter("Stored_proce", DatabaseConfiguration.createConnection
I hope this will definely sort me out.
Thanks a million Rob.
|
|
|
|
|
I think you can use the first approach. Personally I'd create a connection, then create a command, then attach the adapter to that but its just personal preference.
You can reuse your connection if doing lots of things that way.
Regards,
Rob Philpott.
|
|
|
|
|
Thank very much for your help Rob.I will keep you posted.
Many thanks
|
|
|
|
|
Hello everybody
I am a real beginner in C# programming language.
I have a binary file, with binary data (ok). I would like to find a specific string in the file and make calculation of the found values.
Example: In the binary file, I have : "#{'"éé&$$¨DATAFOUNDllolml"{MYDATA|||\$$^p^££"
How can I do to capture MYDATA, using DATAFOUND as a key entry.
In my whole file, after DATAFOUND I have 8 bytes and then the searched values (here it's MYDATA).
Any advice and help are welcome.
PS: I am new programmer and I am not from an English speaking country...So be comprehensive.
|
|
|
|
|
mamamiya_ wrote: Hello everybody
welcome to CodeProject
mamamiya_ wrote: I have a binary file
For File I/O discussions "binary" means the data in the file contains bytes with the value of ZERO. In that case using String library functions are problematic.
mamamiya_ wrote: How can I
You need to parse the file. If, as discussed above, the data is all string data then there are numerous methods such as Regular Expressions. However deciding the best method of parsing and searching the data requires a knowledge of the file format.
|
|
|
|
|
Finding the string is trivial (and I assume that your data begins immediately after the string), but how do you know where your data ends, or even how much data there is?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
The data are always 8 bytes long.
|
|
|
|
|
|
suni_dotnet wrote: my page postbacks many times and this button click occurs in between.
"in betweeen" what?
|
|
|
|
|
I can't figure out what you're trying to do, but since it's asp.net related you're asking in the wrong forum.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
I have written an application using FileSystemWatcher and put the Windows Service on our data server.
Now my question is, using FileSystemWatcher, is there a way to get the windows logon name that actually deleted the file? I realy want to know who deleted or created the files. Is this possible?
|
|
|
|
|
Depending on what Windows Server OS you have and how it's configured (NTFS I think) I believe Windows is capable of auditing the File System. You need to configure it of course.
|
|
|
|
|
Our data server is running Server 2008 x64.
So are you saying Windows has something built in instead of writing an app for it?
|
|
|
|
|
Jacob D Dixon wrote: So are you saying Windows has something built in instead of writing an app for it?
Yes, I've never used it so I don't know where the MMC is located. It will write entries into the Security Log.
|
|
|
|
|
Ohh! Your talking about the File Screening. I think that just monitors saving files not deleting. I currently use that to block non image files from being saved to our images drive. Or are you speaking of somethign else?
I guess I'm still wondering if using FileSystemWatcher can get the users login name?
|
|
|
|
|
Jacob D Dixon wrote: Ohh! Your talking about the File Screening. I think that just monitors saving files not deleting.
No, I'm talking about File System Auditing and it can Audit just about everything I believe.
|
|
|
|
|
Ok I see what you are talking about.
Thanks...
I'm still curious if the FileSystemWatcher can do something like that.
|
|
|
|
|
Yes, just get the currently logged on user name at the time you detect a file being deleted.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
The Windows Service that I made goes on a Data Server.
The way everyone accesses it is by mapping a network drive (to the Data server) on their desktop PC's.
So on the server using FileSystemWatcher can you get their information? The service is running under local system, but the person actually doing the deleting will be using a desktop PC that just has that network drive mapped. How do I get that person's logon name to log that they were the ones that deleted it?
|
|
|
|
|
|
Hi there,
I'm using (trying to use ) webbrowser control in C# windows application.
When I'd like to page down there is a y variable, I'm adding 50 to y and I use
y = y + 50;
webBrowser.Document.Window.ScrollTo(x, y); // like this x=0
So I need to get value of y, when I come to end of the page.
Is there any method of property of webbrowser that returns something which we understand if we come to end of the pages?
Many thanks.
Muharrem.
|
|
|
|
|
You can use the AutoScrollOffset Property.
|
|
|
|