|
Have you heard about arrays?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
yes, but how will I implement it by not touching any of the MyModule code? I only want to add to the configuration file, so each time I add a vendor I don't have to change the code
Can you please provide a code so that I'll know if what you're suggesting is feasible on my part?
|
|
|
|
|
Simply set the number of vendors in you configuration file and then create an array of vendors with the required size at runtime.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Is this how you're suggesting it?
public struct Example1
{
public int Vendor1;
public int Vendor2;
public int vendorcount =2;
}
class MyModule
{
int[] newint = new int[vendorcount];
for(int x=1; x<vendorcount;x++)>
{
newint[x] = Exmaple1.Vendor1; ,--- (PROBLEM) how to point to Vendor2, vendor 3
}
}
how will be able to iterate through Vendor1 to Vendor2 (to vendor3 and so forth)? If I do this I'll have to change code on the MyModule class. I need to avoid having to change the code each time I add a new vendor
|
|
|
|
|
Nope.
I mean something similar to
class Example
{
public Example(int count){ vendor = new Vendor[count];}
public Vendor[] vendor;
};
class Program
{
public static void Main()
{
Example example = new Example(vendorCount);
}
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I think this might work. Thanks!
|
|
|
|
|
Hi,
Any clean idea on how to load a tree-like structure "eg. nested folders" into a treeview control?? I know I have to use recursion but I dont have the guts to do it
Please, shed some light on me if you have a previous experience in such problem.
Thanks guys!
To define recursion, we must first define recursion!
(\ /)
(O.o)
(><)
|
|
|
|
|
private void Dig(string file)
{
DirFiles = Directory.GetFileSystemEntries(file);
foreach (string subFile in DirFiles)
{
FileInfo SubFi = new FileInfo(subFile);
if (!SubFi.Attributes.ToString().Contains("Directory"))
if (!listBox1.Items.Contains(subFile))
listBox1.Items.Add(subFile);
else
Dig(subFile);
}
}
I think I have the guts to do it after all
C'mon, give me five
All generalizations are wrong, including this one!
(\ /)
(O.o)
(><)
|
|
|
|
|
Hi,
I am trying to open a MS Access database from C# code.
I want the MSAccess database to open up on a button click.
Am able to create a connection to the database but am unable to open the database.
i want the database to be open on a button click event so that i can open a table.
Atached below is my code.Any help is welcome .
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ADOX;
using System.Data.OleDb;
using System.Runtime.InteropServices;
namespace DatabaseCreation
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string strAccessConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + txtdatabaseName.Text;
OleDbConnection myAccessConn = null;
try
{
myAccessConn = new OleDbConnection(strAccessConn);
myAccessConn.Open();
MessageBox.Show("Database connection is successfully Opened");
}
catch (Exception ex)
{
MessageBox.Show("Error: Failed to create a database connection. \n{0}", ex.Message);
}
if (myAccessConn.State == ConnectionState.Open)
{
myAccessConn.Close();
MessageBox.Show("Database is successfully Closed");
}
}
}
}
modified on Wednesday, April 23, 2008 5:40 AM
|
|
|
|
|
So you know in the future. If no one has responded to your question you have the ability to delete the message using the 'Delete' button in the lower right hand corner of the message.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Hi ,
I create a xml string using a xmldocument (c# 2.0 )
This is my code (more or less)
XmlElement MySearchNode = xmlDoc.CreateElement("MySearch");
xmlDoc.AppendChild(MySearchNode);
...
XmlNode node1 = xmlDoc.SelectSingleNode("/MySearch/Objects");
XmlAttribute nameAttrib = xmlDoc.CreateAttribute("result");
nameAttrib.Value = "012";
node1.Attributes.Append(nameAttrib);
xmlDoc.outerxml
I want to validate the xml string against a XSD :
XmlReader rdr = null;
XmlParserContext context = new XmlParserContext(null, null, "", XmlSpace.None);
XmlTextReader readerXml = new XmlTextReader(p_xml, XmlNodeType.Element, context);
XmlTextReader readerSchema = new XmlTextReader(p_xsdPath);
XmlSchema schema = new XmlSchema();
schema = XmlSchema.Read(readerSchema, new
ValidationEventHandler(Schema_ValidationEventHandler));
XmlReaderSettings ReaderSettings = new XmlReaderSettings();
ReaderSettings.ValidationType = ValidationType.Schema;
ReaderSettings.Schemas.Add(schema);
ReaderSettings.ConformanceLevel = ConformanceLevel.Fragment;
ReaderSettings.ValidationEventHandler += new
ValidationEventHandler(settings_ValidationEventHandler);
rdr = XmlReader.Create(readerXml, ReaderSettings);
this is my XSD
(a part of it)
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="MySearch">
<xs:complexType>
<xs:sequence>
<xs:element name="Objects" type="tObjects" minOccurs="0" maxOccurs="1" />
</xs:sequence>
<xs:attribute name="result" type="xs:string" />
</xs:complexType>
</xs:element>
<xs:complexType name="tObjects">
<xs:sequence>
<xs:element name="House" type="tHouse" minOccurs="0" maxOccurs="unbounded">
</xs:element>
<xs:element name="Garden" type="tGarden" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
....
Note : this is my xml string
<MySearch>
<Objects result = '012' >
<House>
...
</House>
</Objects>
</MySearch>
when I validate I get this error :
The 'result' attribute is not declared.
I see that validation process need :
ReaderSettings.ValidationFlags = XmlSchemaValidationFlags.AllowXmlAttributes;
and
attributeFormDefault="unqualified" .
It doesn't work !! I always get the same error ..
Could you help me ? thanks in advance .
|
|
|
|
|
I Have Return the validation expression(Alpha,Numeric,special character) in three regular expression.
How to write the multiple validation expression in single Regular Expression.
Alpha
******
Regex rx = new Regex(@"^[a-zA-Z]+$");
Numeric
*******
Regex rx1 = new Regex(@"^\d+$");
special character
*****************
Regex rx2 = new Regex("[@#$%^&*()_+=?><.,\":;~`|\\?/}{]+$");
|
|
|
|
|
I have heard that .NET framework is redistributable..
Does it mean that it is free??
If I build a client application in .NET, certainly I would need the framework, that why I want to know that can I install it in the clients system without any licensing hassles??
Are all latest frameworks free or the only the old ones? (upto 2.0) ??
|
|
|
|
|
Yes, all versions (so far) are free. I believe that framework 2 is usually included with Vista - I don't run Vista so I'm not sure.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
What made you think they were not be ? Did you try searching for info ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
So what is the Difference between .NET framework 3.0 and .NET framework 3.0 redistributable package??
|
|
|
|
|
One is the whole framework, which is free, and can be used to write apps, even without visual studio. The other is just the bit the end user needs to run your code.
There is a free IDE as well, so I don't think many people use just the free framework anymore.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Christian Graus wrote: One is the whole framework, which is free, and can be used to write apps, even without visual studio.
Now this is very interesting..
Culd you please elaborate more on this?
How can I write apps in .NET framework without Visual Studio??
Do I have to use an editor of some other vendor for this?
|
|
|
|
|
ptr2void wrote: How can I write apps in .NET framework without Visual Studio??
Sharpdevelop [^] is an open source IDE .
BTW Visual C# Express Edition [^] is free.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I used SharpDevelop in College...
*Shudders*
Visual C# Express Edition or Notepad :p (Or preferably EditPad Lite instead of Notepad, but that's just me... )
|
|
|
|
|
I fully disagree : I used Sharpdevelop (only a bit, I admit) and like it.
Visual C# Express Edition is great value for money (BTW Notepad++ is much better than Notepad ).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Great value for money... Lol :p
And my response with my SharpDevelop experience might be directly related to the fact that I was using it in 2005, when it was still in Beta....
|
|
|
|
|
Is Visual Studio still in beta or am I wrong?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
You may use Notepad if you wish. The compiler is a free download.
|
|
|
|
|