|
A useful article[^] from MSDN magazine about usage of WMI, which was already mentioned as solution for your problem.
www.troschuetz.de
|
|
|
|
|
Ok here is the question, Im useing Mysqldrivercs and ive got a dataSet with a table thats populated already, the same way on my Mysql server.. but I cant seem to get the data from the mysql server to load into my datagrid's dataset.. anyone have this problem? or have a sample code for it?
Thanks
|
|
|
|
|
Post some code, show us how you are updating the database and hopefully someone can point you in the right direction. Personally i would use a SqlDataAdapter to update the database from the dataset.
DataSet ds = new DataSet();<br />
System.Data.SqlClient.SqlDataAdapter sql = new System.Data.SqlClient.SqlDataAdapter();<br />
sql.Update(ds);
If thats not what you're trying to do then post a bit more info.
Cheers
Kev Pearman MCP
|
|
|
|
|
MySQLDataAdapter da = new MySQLDataAdapter();
MySQLConnection con = new MySQLConnection();
con = new MySQLConnection(new MySQLConnectionString(ip,
dbname,
username,
password).AsString);
con.Open();
MySQLCommand sql = new MySQLCommand("SELECT * FROM `character`",con);
MySQLDataReader reader = sql.ExecuteReaderEx();
if(reader.Read())
{
conn.Text = "Yes";
while(reader.Read())
{
}
}
reader.Close();
sql.Dispose();
con.Close();
}
where its while(reader.Read())
{
}
Ive put da.Fill(ds);
but thats not what I need.
|
|
|
|
|
To write back to the database use da.Update(ds);
da.Fill fills a dataset, if i understand what you are asking for you want to update the database from the dataset, this is where the .Update command comes in.
Kev Pearman MCP
|
|
|
|
|
thanks yeah I do want to have an update but thats a differnt story
Right now im trying to get it to load the data from my sql server to my client's dataset table.
|
|
|
|
|
OK, sorry i guess i got the wrong end of the stick there
You said in your previous post that da.Fill(DataSet) doesn't work.
This is how i would fill a DataSet from a DataAdapter, why is the Fill method not OK for yourself?
Kev Pearman MCP
|
|
|
|
|
Now I get an error:
System.InvalidOperationException: The SelectCommand property has not been initialized before calling 'Fill'.
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
|
|
|
|
|
You have to write the Select command for the data adapter so it knows what fields to pull out of the database. If you are using Visual Studio then just drag and drop a DataAdapter onto you form and it wil open a wizard. Follow the prompts and the select command will be created for you along with Update, Delete and Insert statements, as long as you specify the primary key for your data.
If you are not using visual studio then you will have to create the SQL statements for selecting and updating the data required and assign them to the relevant properties of your DataAdapter
Kev Pearman MCP
|
|
|
|
|
Im useing VS .NET 7.1, I didnt get a wizard when I did that, but it did put the adapter there.. is there a howto on setting up these commands properly?
Thanks
|
|
|
|
|
I'm sure there's plenty of info out there about setting up the command properties of a DataAdapter but i really couldn't tell you where. Try MSDN or search the forums for something.
If that doesn't work then try reposting at the front of the forums and ask specifically for help on setting up DataAdapters Command properties, i'm sure someone will have a link to a document you could use.
Kev Pearman MCP
|
|
|
|
|
Thanks exhaulted I got it to post to the datagrid now.. However now im running into a problem with insert and update lol..
Thanks again for helping me with the other end
|
|
|
|
|
Simple question:
After using this window plus the Watch window in VB(6,.net) using functions like substring, indexof, trim around variables like
?var.Substring(0,1) IN C# I get the error(s) for ALL functions (out of scope, does not exist,etc.) There must be a way out of this, besides having to break the routine, put a debug statement around the variable, recompile and watch!!! ARGH!
HELP
|
|
|
|
|
yeah, these function are not in C# as VB 6.0 for sure.
you can debug by puting a break point anywhere, you have the watch window, locals and autos.
|
|
|
|
|
I'm dumbfounded!!
You mean, if I want to experiment on the fly with some parsing problem, I can only do this after a compile??? and not real time?? What a huge disadvantage...
How do you work out the kinks without pulling your hair out....
Even setting a watch to let's say val.Trim(), throws and error!!! but I would presume that foo=bar.Trim()
watch on foo won't!!!
Awful!
|
|
|
|
|
yeah, life isn't easy!
why don't you save the day and post some VB code and i'll help you translating it to C#.
becuase i really don't know where i should start to help you.
|
|
|
|
|
I think I'll build an Add-In
|
|
|
|
|
Hi,
I want to do that my program reads data from version1.mdb file and write the same data to the version2.mdb by using C#.net but I am new and dont know how todo this.
I want to hold the data at first by a recordset after reading from version1.mdb and to write to the version2.mdb file.
please help me, thanks
|
|
|
|
|
All you need to do is read the data from version1 into your DataSet using a DataAdapter .
Create a second DataAdapter and point it at the second database.
call the DataAdapter2.Update method specifying your Dataset as the source to update from.
DataAdapter2.Update(DataSet);
As long as both of the databases have the same structure and you have a primary key defined in each you shouldn't have too many problems.
Hope that helps.
Kev Pearman MCP
|
|
|
|
|
Hi,
I am trying to use a class from two different assemblies. This class is contained in the same namespace in the assemblies. These assemblies are referenced in the same project and I want to be able to use both classes.
Ex:
MyClass is under MyNamespace namespace in Assembly1.dll
MyClass is under MyNamespace namespace in Assembly2.dll
Assembly1.dll and Assembly2.dll are referenced in MyProject project. How can I use MyClass class from both assemblies.
Best Regards
|
|
|
|
|
Try the following
<br />
Assembly1.MyClass class1 = new Assembly1.MyClass();<br />
Assembly2.MyClass class2 = new Assembly2.MyClass();<br />
If you fully qualify your references to the namespaces you should be fine.
Kev Pearman MCP
|
|
|
|
|
Lol those are the assembly names, not the namespaces. He mentions both reside in the same namespace, called MyNamespace.
top secret xacc-ide 0.0.1
|
|
|
|
|
:-ODoh! Now i feel stupid!
Kev Pearman MCP
|
|
|
|
|
|
The posts are all yours now, dinner times over so i gotta get back to it
Kev Pearman MCP
|
|
|
|