|
how to connect MS acess with C#.NET
|
|
|
|
|
s4_sabahatf wrote: how to connect MS acess with C#.NET
The real question is are you capable of looking at the list of C# Database Articles here on CodeProject that surely contain the answers you seek?
|
|
|
|
|
Have a look at this website: http://www.connectionstrings.com/
|
|
|
|
|
Use a connection string. Like Giorgi said, go to http://www.connectionstrings.com[^], better yet, bookmark the site
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
I think I read (or dreamed and hoped) that there was an attribute you could use on a class to disable the designer support. Specifically, write a class that inherits a control or datarow or anything with a designer and double clicking on the class file then defaults to design mode. Sometimes I never want the designer.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
Hi,
I usually add the line
[System.ComponentModel.DesignerCategory("Code")]
right above the class statement for this.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
That is exactly what I was trying to remember. Thanks.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
Huh, and all this time I've been using "right-click|view code".
|
|
|
|
|
So why didn't you ask?
I have one question for you (or anyone who digs deeper on this):
having partial classes in two or more files, how can one have one file that opens
by default in Designer whereas the other(s) open in code view?
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Now my brain hurts...
|
|
|
|
|
Come to think of it... maybe it's been fixed in VS 2005... but as I recall, in VS 2002/2003, the Designer wanted to design the first class in the file, so if you added some helper class you had to add it after your form, or the Designer would sit there looking stupid.
Maybe in the additional files you could add some class simply to have that attribute?
Dang... now I gotta try it...
-- modified at 22:58 Friday 12th October, 2007
Nope, didn't work. But I notice that the xxx.Designer.cs works the way you describe, so I'll look at how those are set up in the project file...
-- modified at 23:07 Friday 12th October, 2007
That turned out to be more difficult than I expected.
Step 1: Add a new Code File, the name should begin with the name of the form (like the xxx.Designer.cs file).
Step 2: Close the Solution
Step 3: Edit the project file, change
<Compile Include="Form1.CodeFile1.cs" />
to
<Compile Include="Form1.CodeFile1.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
(using whatever names you chose)
Step 4: Open the Solution
Step 5: Close the Solution
Step 6: Edit the Code File to have the namespace and class stuff
Step 7: Open the Solution
VS should have the ability to add other pieces of a Form class built in.
I also noticed that when a file is DependentUpon, it can be deleted, but not removed or renamed.
-- modified at 23:46 Friday 12th October, 2007
|
|
|
|
|
PIEBALDconsult wrote: the Designer wanted to design the first class in the file
Yeah I think that restriction got relaxed, it does not get at me anymore, maybe they
solved it, maybe I don't even try it anymore.
PIEBALDconsult wrote: Maybe in the additional files you could add some class simply to have that attribute?
in my limited experiments it either ignores the additions, or it complains about
inconsistency. So any input will be appreciated.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I tried it, VS just gives a better message explaining the situation.
|
|
|
|
|
You can also make code view the default and open the designer only when you use "right-click|view designer".
Right-click a Control/Form file and choose "Open with", then choose "CSharp Editor" and click "Set as Default".
|
|
|
|
|
hi
Does http channel supports bidirection connection over the internet?
Actually i need to trigger some events at the client application resides behind firewall/proxy/NAT network from the server running at public IP out side my network.
naresh is testing the site.
|
|
|
|
|
dhami_naresh wrote: Actually i need to trigger some events at the client
HTTP[^] does not support that.
|
|
|
|
|
Thank you very much Led Mike,
Actually i am using http channel of dot net remoting. Client can connect to server(server in out side my network) channel via this http channel implementation in .net remoting and can send data to server but we need to trigger some events from server to client via this channel. So the problem is server cant send any type of message to the client.
So please may be some addons those could help on solving this problems or may be some sample application those are teaching the same things. Please if you know, send me those references.
thank you in advance.
naresh is testing the site.
|
|
|
|
|
HTTP is a protocol that is used over TCP/IP. It does not support what you describe. Perhaps using another IPC mechanism would provide you with a solution. Have you looked into Message Queues? Or even creating a proprietary protocol using Sockets?
|
|
|
|
|
thank you again Mike,
i search out those thing what you suggested.
thank you verch much.
naresh is testing the site.
|
|
|
|
|
Hi Guys,
I have added a basic logon form that gets a users logon name and password and matches that to a given list to my project. Once it has been validated it calls the main form. Now, the problem I have is that when it calls the main form I can't connect to the db. The user validation is done in the logon form class as you can see below.
private void button1_Click(object sender, EventArgs e)
{
frmNef frm1 = new frmNef();
if (textBox1.Text == "maphanga" && textBox2.Text == "marsha" || textBox1.Text == "nkosi" && textBox2.Text == "mdu" || textBox1.Text == "carrim" && textBox2.Text == "allerece" || textBox1.Text == "raphela" && textBox2.Text == "rachel" || textBox1.Text == "mazibuko" && textBox2.Text == "zoliswa")
{
this.DialogResult = DialogResult.OK;
}
else MessageBox.Show("Invalid Username and or Password supplied");
}
This is then validated in the main form's load event.
private void frmNef_Load(object sender, EventArgs e)
{
Login login = new Login();
if (login.ShowDialog(this) == DialogResult.OK)
{
return;
}
else this.Close();
login.Close();
login.Dispose();
Can somebody please tell me how I can do this better so as to get the connection to the DB working properly with the logon form? I had to remove the logon form before the app would work again.
Thanking you in advance.
|
|
|
|
|
Kwagga wrote: I can't connect to the db.
Yeah it requires some code or something to do that. Your posted code contains nothing that connects to a database. There are a large number of articles here on CodeProject about Database development using C#. Perhaps you might look at them.
|
|
|
|
|
Sorry mate. The db connection works fine when I remove the logon form code. When I add the logon form code in I can't see anything in the DB, nor can I save anything back in. It is almost as if the logon form is not releasing focus to the main form. However it opens the main form OK but I guess it might be that it loops somewhere or doing something silly like that which I just can't seem to figure out.
Anyway, here is more code from the main form.
Login login = new Login();
if (login.ShowDialog() == DialogResult.OK)
{
return;
}
else this.Close();
login.Close();
login.Dispose();
try
{
DateTime dtCurrentTime = DateTime.Now;
tlstrlblTime.Text = dtCurrentTime.ToShortTimeString();
DateTime dtCurrentDate = DateTime.Today;
tlstrlblDate.Text = dtCurrentDate.ToShortDateString();
m_cnADONetConnection.ConnectionString =
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\CallCentre.mdb";
m_cnADONetConnection.Open();
m_daDataAdapter =
new OleDbDataAdapter("Select * From [CallCentre]", m_cnADONetConnection);
OleDbCommandBuilder m_cbCommandbuilder =
new OleDbCommandBuilder(m_daDataAdapter);
m_daDataAdapter.Fill(m_dtCallCentre);
this.ShowCurrentRecord();
If you can point me to some of the posts I would greatly appreciate it. I have been searching here and on Google but none of the topics i find actauly refers to what I'm doing. Most of them are for web development.
|
|
|
|
|
Kwagga wrote: if (login.ShowDialog() == DialogResult.OK)
{
return;
}
|
|
|
|
|
Thanks mate but what about the "return"? I don't understand what you trying to say.
|
|
|
|
|
He is saying that the return statement you have is dropping you out of the procedure. Because of it, you aren't ever getting to the try block...
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|