|
zamazula wrote:
Is there a class or library or whatever???
You will need ODBC.NET[^] and then also MyODBC[^].
Hope this helps,
Nathan
---------------------------
Hmmm... what's a signature?
|
|
|
|
|
I needed to access a MySql dbase once, so I used dbProvider, it is a managed MySql C# DLL that uses all the same syntax and classes etc as the default SQL ones, I have had no problems with it what-so-ever.
|
|
|
|
|
I am looking for a good way to maintain a clean separation between the GUI, the business objects and the persistence mechanism. It seem as though the forms/asp environment is geared to directly couple the DB with fields on a form. In general, I try to have my GUIs stay dumb and only know about the underlying business objects. Then the business objects either know how to persist themselves, or what to use for a persistence mechanism.
What's the C# / dotNet best practice for keeping these layers distinct?
Thanks,
Bryan
|
|
|
|
|
Hi,
In my program I need after doing some job to be able to shut down the system.
So I wrote that code:
public event SessionEndedEventHandler ShutDown;
protected virtual void OnShutDown(SessionEndedEventArgs e)
{
ShutDown(this,e);
}
and then I wanted on a button click to raise the event:
private void button1_Click(object sender, System.EventArgs e)
{
OnShutDown(new SessionEndedEventArgs(SessionEndReasons.SystemShutdown));
}
But I always get System.NullReferenceException
Anyone has an idea how to solve this problem ?
Thanx in advance
Cheers,
Gogou
GAtanasov
|
|
|
|
|
Hi,
I think that OnShutDown should check that there is a handler for the event, i.e. the code should be:
if (ShutDown != null) ShutDown(this, e);
Chris Jobson
|
|
|
|
|
Hi, all:
I have a master-detail relationship in my MS Access DB. In my WinForm application, I also created same Master-Detail relationship in my dataset. When I delete a row in my datagrid, the entries in the detail table is also deleted in the dataset due to the relationship. After an user finishs editing the data, I call daMaster.Update and then daDetail.Update. I got the DBConcurrencyException when trying to update the detail table. I think the reason is as following: when the master table is updated, it deletes the row marked with "Deleted". Since the relationship is setup in the MS Access DB, it deletes the entries in the detail table of Access DB. When the second Update is called, the record is gone and exception is thrown.
How do I fix this problem? I can not change the order of update, otherwise it will break the new entries ( must exist in the Master table first ). I guess that if I take all the relationship out in the MS Access DB, it will work fine, but I think that probably is not good thing to do.
Please help. Thanks in advance.
Dion
|
|
|
|
|
Has anyone managed to use GetNativeVariantForObject successfully, I can't make it happen.
If you have some small bit of code to share, that would be wonderful.
(System.Runtime.InteropServices.Marshal.GetNativeVariantForObject)
Preben Rasmussen,
Denmark
|
|
|
|
|
If I hide a column with datagrid.Columns(1).visible = False, and the user enters a new record, how can I set a value to the hidden field so that it gets put in the database? Because when I try to access in this fields, I have a error message like if this field does not exist !!!!!
Could you help me
-=zoltx=-
|
|
|
|
|
In Aspx Dot net......Sorry I forgot
-=zoltx=-
|
|
|
|
|
I read the propertyGrid tutorial and I am reading the RAD property grid discussion. But I fail to grasp the part of taking one property type and having it viewed as another type. The one in particular is where a property represents a file location (type string) yet exposes the File Open dialog box. I am assuming that this would be done via a TypeConverter which converts the property type from string to a File Open dialog, but I am just lost in the implementation.
If anyone knows of a tutorial or the implementation of a TypeConverter for this I'd greatly appreciate the help!
Thanks
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
Hint: use your favourite decompiler and look at System.Design.dll
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
leppie wrote:
favourite
Are you British, leppie?
On to hacking System.Design.dll! Thanks.
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
Whoa, leppie!
I searched both of my drives and there is no System.Design.dll installed anywhere!!! So where is that sucker?
Later,
MJ
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
Oops, never mind. The search engine was not searching system directories. Found it!
Later.
_____________________________________________
The world is a dangerous place. Not because of those that do evil, but because of those who look on and do nothing.
|
|
|
|
|
Hi,
i had to write something like the task scheduler of windows 2000. Do you have any hints about this issue ? Any source code that can give me a start about how doing something ?
i need task to be daily, weekly, monthly and yearly with start date, week of month and day of week.
how to deal with days, weeks and month, are there enum's ?
.:Greets from Jerry Maguire:.
|
|
|
|
|
The System.Diagnostics namespace is your starting point.
Processes tab : enum existing processes
Applications tab : filter out the Processes tab with those that have a main window handle
Performance tab : use perf counters (Performance Counter class)
|
|
|
|
|
sorry, i meant task scheduler not taskmanager, my fault.
.:Greets from Jerry Maguire:.
|
|
|
|
|
There is as I remember an article on that here on CP. Many moons back.
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
When I try to generate an xml file with StringWriter, I can’t change the encoding (UTF-16) to UTF-8. This application, having to have a format xml(utf-8) To preserve compatibility with other programs.
Ex
StringWriter s = new StringWriter();
XmlTextWriter tw = new XmlTextWriter(s,Encoding.UTF-8);
Don’t work, I am receive a error message “C:\Inetpub\wwwroot\LicenceTools\site\GenerateXmlTreeView.aspx.cs(58): Argument '1': cannot convert from 'System.IO.StringWriter' to 'System.IO.Stream'”
I would like having "?xml version="1.0" encoding="utf-8"?" rather than "?xml version="1.0" encoding="utf-16"?"
Could you help me?
Thanks in advance
PS: It s a stream for WebServer.
Application Code:
Htm:
<%@ Page language="c#" Codebehind="GenerateXmlTreeView.aspx.cs" AutoEventWireup="false" Inherits="LicenceTools.site.GenerateXmlTreeView" %>
C#:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using ZZDataFromDb.ZZConn;
using ZZTools.ZZTools;
using System.Xml;
using System.IO;
using System.Globalization;
using System.Text;
using System.Xml.XPath;
namespace LicenceTools.site
{
///
/// Summary description for GenerateXmlTreeView.
///
public class GenerateXmlTreeView : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
//StringReader = new StreamReader("site/GenerateXmlTreeView.aspx");
string strSelect;
// Put user code to initialize the page here
if( Request.QueryString["select"] != null)
{
strSelect =Request.QueryString["select"];
}else {
strSelect= "";
}
string strIdCompany;
if( Request.QueryString["IdCompany"] != null)
{
strIdCompany =Request.QueryString["IdCompany"];
}
else
{
strIdCompany= "%";
}
DataContainer dc=new DataContainer(); // create a data container for this function
dc.Set("select", strSelect); // add the user name
dc.Set("IdCompany", strIdCompany); // add the user name
DBData dts=new DBData(dc); // create a interface to the DB technology
DataTable DT;
DT = dts.QueryMultiRow("sql_fillTreeView"); // query if the account exists. Always returns a value
//Xml Generate
ArrayContainer Level = new ArrayContainer(100);
StringWriter s = new StringWriter();
//string test = s.Encoding.ToString();
XmlTextWriter tw = new XmlTextWriter(s);// ,Encoding.UTF8
tw.Formatting=Formatting.Indented;
tw.WriteStartDocument();
tw.WriteStartElement("treeview");
tw.WriteAttributeString("title","Licenses Tool");
tw.WriteStartElement("custom-parameters");
tw.WriteStartElement("param");
tw.WriteAttributeString("name","shift-width");
tw.WriteAttributeString("value","15");
tw.WriteEndElement();
tw.WriteStartElement("param");
tw.WriteAttributeString("name","img-directory");
tw.WriteAttributeString("img-directory","images/");
tw.WriteEndElement();
tw.WriteEndElement();
int level=0;
string IdElement;
Level.add("");
string Name;
string IdPrduit;
string IdParent;
string License;
string PrevIdParent="";
string PrevIdElement="";
bool FlagElementFirst= true ;
foreach(DataRow r in DT.Rows){
if (FlagElementFirst == true)
{
Level.Remove(0);
Level.add(r["idParent"].ToString());
}
IdElement = r["id"].ToString();
Name = r["Name"].ToString();
IdPrduit = r["IdPrduit"].ToString();
IdParent = r["idParent"].ToString();
License = r["license"].ToString();
if(( Level[IdParent]>=level ||level==0 ))
{
if((IdParent=="" || IdParent!=PrevIdParent ) && (IdPrduit=="") )
{
Console.WriteLine("Name");
tw.WriteStartElement("folder");
tw.WriteAttributeString("title",Name);
if (FlagElementFirst == true)
{
tw.WriteAttributeString("img","folder");
}
else
{
tw.WriteAttributeString("img","folder");
}
level++ ;
Level.add(IdElement);
PrevIdParent=IdParent;
PrevIdElement =IdElement;
}
else if((IdParent==PrevIdParent)&& IdParent!="" && (IdPrduit=="") )
{
}
else if(IdPrduit!="")
{
string reg;
if(License=="Y") {reg="true";}
else {reg="false" ; }
tw.WriteStartElement("leaf");
tw.WriteAttributeString("title",Name);
tw.WriteAttributeString("url", IdElement);
tw.WriteAttributeString("registered",reg);
tw.WriteEndElement();
//tw.WriteAttributeString("test","test");
}
}
else
{
while(level>Level[IdParent])
{
tw.WriteEndElement();
Level.Remove(level);
level--;
}
if(IdPrduit !="")
{
//tw.WriteElementString(Name,IdPrduit);
string reg;
if(License=="Y") {reg="true";}
else {reg="false" ; }
tw.WriteStartElement("leaf");
tw.WriteAttributeString("title",Name);
tw.WriteAttributeString("url",IdElement);
tw.WriteAttributeString("registered",reg);
tw.WriteEndElement();
}
else
{
tw.WriteStartElement("folder");
tw.WriteAttributeString("title",Name);
tw.WriteAttributeString("img","folder.gif");
Level.add(IdElement);
PrevIdParent=IdParent;
PrevIdElement =IdElement;
level++;
}
}
FlagElementFirst = false;
}
tw.WriteEndDocument();
tw.Flush();
tw.Close();
Response.Clear();
Response.ContentEncoding = Encoding.UTF8;//
//Encoding.GetEncoding(1251) ;
Response.ContentType="text/xml";
Response.Write(s.ToString());
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
-=zoltx=-
|
|
|
|
|
using System.IO;
using System.Xml;
MemoryStream ms = new MemoryStream();
XmlTextWriter tw = new XmlTextWriter(ms,new System.Text.UTF8Encoding());
tw.WriteStartDocument();
tw.WriteStartElement("...");
tw.WriteEndElement();
tw.WriteEndDocument();
tw.Flush();
tw.Close();
String s = System.Text.Encoding.UTF8.GetString( ms.GetBuffer() );
MessageBox.Show( s );
|
|
|
|
|
Thanks a lot. It works..... somebody, send me an others solution which work too
public class StringWriterWithEncoding : StringWriter
{
Encoding encoding;
public StringWriterWithEncoding (Encoding encoding)
{
this.encoding = encoding;
}
public override Encoding Encoding
{
get { return encoding; }
}
}
Then you'd do:
XmlTextWriter = new XmlTextWriter
(new StringWriterWithEncoding (Encoding.UTF8));
-=zoltx=-
|
|
|
|
|
I have to admit the StringWriter derived class is a much better approach to the encoding issue. Use it instead of the C-like memory streams I have suggested.
|
|
|
|
|
You are great ........ Thanks a lot ......
-=zoltx=-
|
|
|
|
|
Hello,
Is there a way a class can access private and protected members of another class? Like friend keyword in C++. I haven't discovered it.
Thanks!
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
Alexandru,
a similar construct to friend is the internal keyword, which allows access from within the same assembly, but not from outside.
Wolfgang
|
|
|
|