|
he means he wants something like
"Create table mytable ID int Not null, somevalue varchar2(10), " etc.
V.
I found a living worth working for, but haven't found work worth living for.
|
|
|
|
|
Hi all,
Im kinda starter in C#.net, im trying to build a system, first thing's to establish a connection to an MSAccess DB, I want to make my connection public so all forms can use it by just calling it. I'm trying to work on creating a class for it but im having hardtime making it work...
How can I make a public connection in a class and call it in my forms?
Thanks in advance
-::maximus::-
|
|
|
|
|
Try to make a class like "DatabaseManager" to do all the databaseoperations
Please make all the methods as public so that all the classes can access them
You can use the following public methods
1.OpenConnection()
2.CloseConnection()
3.ExcecuteQuery(string query)
4 ExecuteQuery(string query,out Dataset dt)
Just call Excecute query function with a query,and you can managethe open and close connection from this function.
If you expect any output(like search) then you can use the overloaded function
which gives a dataset.
My small attempt...
|
|
|
|
|
Hi,
the idea with one class for the hole project is a good one.
You can create a oleDbDataAdpater with the Windows Forms generator.
Then you copy the source and put it into a new class, which is created by your own. Set the modifier to public and now you can use your class in the hole project.
regards
spotl
|
|
|
|
|
Hi,
I am new to SQLExpress (although not SQL) and am about to create a project in C# using it instead of MS Access.
I am a bit confused about some issues and would like advice/guidence on these issues please:
1. In the VS2005 IDE I can view the db, add tables etc manually which avoids the need of moving backwards and forwards with SQL Server Manager which is good.
As I have previously distributed my Access db in a subdirectory of the main program without problems, I would like to think I can do the same with the new .mdf file.
When coding however, the connection string would appear to require it to point to the orginal db in VS2005 Studio as follows:
string dbLocation = @"d:\vs2005 projects\mybookings\mybookings\mybookings.mdf";<br />
string connectionString = "Data Source=.\\SQLExpress;Integrated Security=True;Timeout=60;Initial Catalog = MyBookings;Application Name=SQLExpressTest;AttachDBFilename=" + dbLocation;
If I point the connection string to the copy of the db file in the subdirectory of the main program (like I do with MS Access) then I keep getting connection errors.
The question is - "How will this affect my program when I distribute it as obviously the connection string will point nowhere?"
2. I think I must be missing some basic understanding of use and deployment of SQLExpress enabled programs and would appreciate any references to any online sites you may be aware of. I've looked at the MSDN site and read the information there and no doubt I will eventually master it. However, the above problem concerns me now and I don't wish to start of wrong and have to go back and re-do my code. Unfortunately, almost everything I can find on this subject relates to ASP.Net and vb (which I find difficult to interpret particularly when I am trying to learn the subject - not the language).
TIA.
PS. PLease forgive the xpost but I think in this case it was warranted.
Glen Harvy
|
|
|
|
|
The MSSQL service needs to know about the database for the database to work. I've just looked up the attachDBFileName property and it looks like it should attach the db so all should be well.
http:MSDN article
this article mentions a couple of potential issues:
The db file must be writable.
You might not want to copy in the ldf file as it should create a new one when you first connect.
A problem i had in the past with copying mdf files was that if you haven't detached it before you copy it, it might not be in a consistent state and then it fails to reattach properly
HTH
Russ
PS posting the connection errors you are getting might help.
|
|
|
|
|
Hi,
First of all - thank you for your response.
I have progressed somewhat in that I discovered the following matters.
1. When FIRST accessing the database from my program I need to use the full path name to the .mdf file in my connection string.
2. Subsequent connections need only refer to the database name.
This makes sense to me as the first time I accessed it, the db was included in the SQLExpress Server. Once known to SQLExpress Server I need only refer to the database by name.
I will worry about this more when I come to deploy my project however I am confident enough to see that all I will need to do is install my db into SQLExpress Server on installation of my program and all will then be fine.
BTW I think this is an adverse side affect of using IDE's as I would have thought that by using the VS2005 IDE to create and ammend my SQLExpress db, VS2005 would have "registered" the db with SQLExpress making the connection string almost so simple it's not even needed!
Your thoughts and comments would be appreciated - it's very lonely trying to program in a remote corner of the world.
Thanks for your support,
Regards,
-- modified at 5:51 Tuesday 20th March, 2007
Glen Harvy
|
|
|
|
|
Hang in there
If you attach your DB in your SQL server you normally have no need for the .mdf file, although I can't verify if it's the same in SQLExpress. If it is possible to attach a DB-file to a SQLExpress server, you will only need a connectionstring once your application is properly deployed.
btw I live in Belgium, at least more people know where your country is
Visual Studio can't evaluate this, can you?
public object moo<br />
{<br />
__get { return moo; }<br />
__set { moo = value; }<br />
}
|
|
|
|
|
Thanks,
Actually I figured out how to get it to work by going into SQL Server BUT my main concern was that when I deploy the project there is no way I could expect the end-user to have any idea how to do it "manually".
As you have noted - once I got it attached to SQLExpress Server, I no longer had any deployment worries.
Thanks for your support - it gets pretty darned hard to search the internet for help when you just don't know what to put in your search. Often I get led astray and discover that the solution to the problem that I am reading about is not actually the problem I am having at all
Cheers,
Glen Harvy
|
|
|
|
|
i would guess that you should already be able to connect by name to the db if you're using the IDE.
create a text file called something.udl. Double click it, select sql server from the provider tab and then put your name / connection credentials etc and select the db from the list it gives you. You can then check the db connection from here and make sure everything is working without your code or the ide being involved.
The cool trick then is to open this file in notepad and there is your functioning connection string. You need to delete the provider section these days, but that string should work as is (apart from password which you can add manually)
HTH
Russ
|
|
|
|
|
Russell Jones wrote: i would guess that you should already be able to connect by name to the db if you're using the IDE.
I would have thought so as well but no - you need to connect once as far as I can tell with the full path to the db file to get the db into the SQLExpress Server database. At least I had to - someone will prbably tell me that there is an easier way but until they do I will stick to this way - it's not as if I start a new project every day
I was amazed at the .udl file and thanks - did exactly as you said and what a neat trick
Glen Harvy
|
|
|
|
|
|
Hello everyone,
I have a PHP file which is holding some data which I would like to enter into an Windows Application written in C#.
I have no clue what so ever and I have no idea where to start. Could you be kind enough to tell me how this can be done and where I need to start?
I am not sure if this is even possible to be honest with you. Maybe I cannot use PHP and should get ASP.NET for this?!!! Anyways, I welcome any suggestion.
Thank you very much and have a great day.
Khoramdin
-- modified at 22:05 Monday 19th March, 2007
|
|
|
|
|
|
Hello Kumar,
I am not sure what you mean by "a Web-service". Could you be more specific, please?
Thank you so much for the input, mate.
Khoramdin
|
|
|
|
|
I'm not quite sure if I understand. Do you want to take the PHP file and put into a datagrid? Or do you just want to display it as a website? (I don't know what a PHP file is) To open it you can do this....
<br />
Filestream file = new Filestream(YourPHP.PHP);<br />
StreamReader sr = new StreamReader(file);<br />
string s = sr.ReadToEnd();<br />
sr.close();<br />
file.close();<br />
But you don't do that if you just want to display it in a WebBrowser.
Hope this helps, but if not, let me know.
|
|
|
|
|
You can put a webbrowser control into your site and just point the URL to your PHP site. A web service is a program that passes data over the web, not through pages, but as XML. Google will tell you more.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello Christian,
Thanx for the reply. That is exactly what I am doing as I placed a webbrowser control in the Windows Application which is pointing to my php file. Now I have the executed php file displayed in the webbrowser control, containing the information "data" that I need to have available in the Windows Application as variables.
How on earth I can get the displayed data into the Windows Application and use those variables in the C# programing?
Thank you very much for your help.
Khoramdin
|
|
|
|
|
This discussion will have many interesting links for you:
Read Web Page .NET C#[^]
Visual Studio can't evaluate this, can you?
public object moo<br />
{<br />
__get { return moo; }<br />
__set { moo = value; }<br />
}
|
|
|
|
|
I have no idea.
Basically, I want to do the following:
1) get reference to whatever object has focus.
2) give another control focus.
3) do some stuff with control from 2)
4) give focus back to the initial object.
I don't know how to do 1) and 4), but I'm sure I could figure out 4), given 1) (but not vice-versa).
So - can anyone help me with 1)?
Thanks!
cdj
|
|
|
|
|
okay. The first one is probably going to be the hardest one to answer. I don't think the form has any methods or properties that tell you which has focus, but you could do a foreach statement which would look something like
<br />
public Control FocusedControl()<br />
{<br />
foreach (Control Ctrl in this.Controls)<br />
{<br />
if (Ctrl.Focused == true)<br />
return Ctrl;<br />
else<br />
return FocusedControl;<br />
}<br />
}<br />
}
I am not sure if it will let you return the focused control, in which case you could use a different iteration
<br />
public Control FocusedControl()<br />
{<br />
Control FocusedCtrl = null;<br />
Int FocusIndex = 0;<br />
while (FocusedCtrl == null && FocusIndex < this.Controls.Count)<br />
{<br />
if (this.Controls[FocusIndex].Focused == true)<br />
{<br />
FocusedCtrl = this.Controls[FocusIndex];<br />
}<br />
}<br />
return FocusedCtrl;<br />
I think either of those will work.
Then to give focus to an object all you need to know is which object you want to give focus to.
MyControl.Focus();
for number 3 I think you mean without knowing the name of it, which you can store in a variable of type Control. To access properties that most controls don't have, such as the url of a webBrowser, you can use
((WebBrowser)this.Controls[FocusIndex]).url = "http://www.codeproject.com";
and finally for number 4 you know how to "store" a Control in the Control variable, and all you have to do is go back to what you named the variable, and use the Focus() method.
Hope this helps.
|
|
|
|
|
For 3), I do know the name of it - there's no problem there. I included the whole sequence just to give the reader the problem-context.
I'd thought of polling every object with a focus property - if I can't come up with anything else, I'll do it. Obviously it's hugely inefficient.
Thanks for your thoughts!
cdj
|
|
|
|
|
Hi to all,
I need to create a little soap client on the http://api.eurocv.eu/euroserver.php wsdl.
Can anyone help me?
Thanks
M.T.
|
|
|
|
|
|
Thank you Vasudevan Deepak Kumar, I would like to create a website using EuroCv. Can you help me to start it?
The web service is here: http://api.eurocv.eu/euroserver.php
contact me by email if you are interested in it.
Best Regards
M.T.
|
|
|
|