|
Use BeginTransaction, Commit and Rollback methods in SQLTransactionClass.
The word "politics" describes the process so well: "Poli" in Latin meaning "many" and "tics" meaning "bloodsucking creatures."
जय हिंद
|
|
|
|
|
Hi d@nish
Yes i know this, but i want to do this by TransactionScope calss and i want to know where does my mistake and how to solve it ?
thanks
|
|
|
|
|
Hi,
Is there any way to avoid restricted method while iterating the method using GetMethods() and properties using GetProperties().
GetMethods() - Using Binding Flags we can filter public ,static,Instance methods.How tofilter out restricted methods.
Generealy Restricted methods are not available for macro progarmming language like VB.
Pls help me ...
By
Rajanbabu
Rajanbabu
|
|
|
|
|
rajanbabu_033 wrote: restricted method
?? You mean Private ?
Read this post Obfuscation[^]
|
|
|
|
|
Hi,
Please help me for the following issues.
In CSharp GetMethods() is returning all the methods and properties of particular Type instead method alone.
How to get the all the methods of particular Type?It should not contain any get,put properties.
I have a sample CSharp program here....
namespace ReflectionDemo
{
class MyClass
{
public void display()
{}
public int RegisterNumber
{
get
{
return 0;
}
set
{
}
}
class ReflectionDemoClass
{
static void Main(string[] args)
{
MyClass mc = new MyClass();
Type tt = mc.GetType();
MethodInfo[] methInfo1 = tt.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);
foreach (MethodInfo mI1 in methInfo1)
{
string methodName = mI1.Name;
System.Console.WriteLine(mI1.Name);
}
}
}
output for this program is :
display
get_RegisterNumber
set_RegisterNumber
Above output have both methods and Properties
but i want to get output : display
Could anyone help me to get this answer(I mean only methods of MyClas not the properties)?
By
Rajanbabu
Rajanbabu
|
|
|
|
|
Hi,
You could use MethodInfo.IsSpecialName , so you'll get the methods only by checking (mI1.IsSpecialName == false )
Calin
|
|
|
|
|
Thanks a lot Calin.It's working fine.This solution is very much helpful for my project.
I have one more clarification also please help me if possible,
Issue :
I hope you are aware that restricted methods are not available for Visual basic users.
E.g.,
interface IFunctionParameterDemo : IDispatch
{
[id(1),restricted,helpstring("method Display")] HRESULT Display();
[id(2),helpstring("method Calculate")] HRESULT Calculate();
};
coclass FunctionParameterDemo
{
[default] interface IFunctionParameterDemo;
};
Here method Display() is marked as restricted by the attribute restricted.So we can't use this method from Visual basic(If we call this method from VB,during compile time it will show error as "Method or Interface marked as restricted")
In reflection is there any way to filter out these restricted methods?
Type t = GetType(FunctionParameterDemo);
MethodInfo[] mInfo = t.GetMethods();
foreach (MethodInfo m in mInfo)
{
System.Console.WriteLine(m.Name);
}
output:
Display()
Calculate()
But I want the output : Calculate()
using GetMethods() i want to get the result of Calculate()alone.It should filter out restricted method Display().
Regards,
M.Rajanbabu.
|
|
|
|
|
Can somebody tell me why this code is not working. It keeps saying
"A datasource instance has not has not been supplied for the data source.
Also I have scoured the web for some good documentation on how to set these up on the fly but I have not found any great info. Can somebody point me in the right direction?
private void toolStripButton1_Click_1(object sender, EventArgs e)
{
this.Cursor = Cursors.WaitCursor;
try
{
// Set Processing Mode
reportViewer1.ProcessingMode = ProcessingMode.Local;
// Set RDL file
reportViewer1.LocalReport.ReportPath = (Application.StartupPath + "\\reports\\trdReport.rdlc");
// Supply a DataTable corresponding to each report data source
reportViewer1.LocalReport.DataSources.Add(
new ReportDataSource("getTrends", LoadData()));
// Add the reportviewer to the form
reportViewer1.Dock = DockStyle.Fill;
// Process and render the report
reportViewer1.RefreshReport();
}
catch (Exception ex)
{
StreamWriter writer = new StreamWriter(logFile, true, System.Text.Encoding.ASCII);
writer.WriteLine(System.DateTime.Now);
writer.WriteLine("[generate report]");
writer.WriteLine("[generate report]");
writer.WriteLine(ex);
writer.WriteLine("\r");
writer.Close();
MessageBox.Show(ex.ToString());
//this.Close();
//System.Environment.Exit(0);
}
this.Cursor = Cursors.Default;
}
private DataTable LoadData()
{
// Load data from XML file
DataSet ds = new DataSet();
string myFilePath = (Application.StartupPath + "\\bin\\" + "trd.xml");
ds.ReadXml(myFilePath);
return ds.Tables[0];
}
tia
rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
It seems that the code works great. I deleted the report file and it worked.
reafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
i am developing c# desktop application. in that i want to connect to mysql database which is resides on another system.please give me an idea about this.
i have already replaced [
Data Source=MySQL Database;Server=localhost; user id=root;password=****;database=sample;pooling=true";] to
[Data Source=MySQL Database;Server=http://192.168.1.64; user id=root;password=gvsadmin;database=sample;pooling=true";]
is there any other way todo this?
thanks
|
|
|
|
|
You're changing the connection string to find the machine on the network. There's no other way to find it than this
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
This is the way I connect to a MySQL database:
string Connectstring = @"server=00.00.00.00;uid=YourUserID;pwd=YourPassword;database=YourDatabase;";
MySqlConnection ConnMySQL;
MySqlCommand cmdMySql = new MySqlCommand();
ConnMySQL = new MySqlConnection(ConnectString());
cmdMySql.Connection = ConnMySQL;
try
{
ConnMySQL.Open();
//Do your stuff
}
catch (Exception e)
{
System.Windows.Forms.MessageBox.Show("Error:" + e.Message + Convert.ToChar(13) + e.GetType().ToString() + Convert.ToChar(13));
return null;
}
finally
{
ConnMySQL.Close();
}
I don't know if this is an answer to your question ?
My assumption is you adjusted SQL server code, but MySQL connection is different.
You also need to set a reference to the .Net connector component provided by MySQL.
Good luck,
|
|
|
|
|
Good people,
I have a quick question. For the screens in my application, before they load, I need to fetch data from the database, perform some calculations, then load it onto the screen. However, rather than the software just freeze up during this process, I would like the progress bar to indicate the, well, progress towards the screen being loaded.
My question is: how do I make the progress bar show the progress during that process of getting data from the database and updating the screen?
Thanks,
Blitz
|
|
|
|
|
|
You are correct!
Thanks,
Blitz
|
|
|
|
|
Hi all,
One of my windows application I want to read a text file and add the result into a list view.
What I've done is read the text file in a background thread. It's fine. But from the thread I cannot add data into the UI thread, basically to the list view. What can I do.
When I try to work on with the UI controls I got the following exception.
Cross-thread operation not valid: Control 'listView1' accessed from a thread other than the thread it was created on.
Can someone give me a comment on this.
If I don't use a background thread, while the text file read the UI is completely stuck and not responding.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
You need to use BeginInvoke[^]/Invoke for cross thread changes.
|
|
|
|
|
Thanks for the comment.
I've solved it using the avoiding the illegal thread calls of the form, with the background thread.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Hi all,
I have written an XML handler class for a project I am currently writing and all the read and write methods do what I expect of them.
It then occurred to me that the main code in this class should be able to do something along the lines of:
section("firstlevel")
{
section("secondlevel")
{
WriteValue("value1", 1);
WriteValue("value2", 2);
}
}
where "section" is a keyword of my XML class and the open and close curly brace calls XmlWriter.WriteStartElement() and XmlWriter.WriteEndElement() respectively creating section tags "firstlevel" and "secondlevel" as they do.
Google searches tend to turn up statements such as "use the keyword new" etc..
Just wondering on where to start on creating a keyword and if there is a suitable example I can follow to get started. Or if I can even do something like this at all.
Regards,
David Bailey.
|
|
|
|
|
You can't create a keyword, but of course you can create classes and methods. I'm wondering whether or not you are describing a recursive method to write out an XML document.
My preferred method of writing XML is by using an XmlDocument and calling its WriteTo method.
More detail would be required to help further.
|
|
|
|
|
Hi PIEBALDconsult,
Thanks for your reply.
No, I was not describing a recursive method. I was aiming for something that was easy to read and configure as well as being specific to a particular class.
What I was trying for was to override the curly braces, but apparently this is not allowed either. The curly braces would then have acted upon the new class keyword "section" to open and then close that section. The WriteValue("value1", 1) method would then place a value into the section.
using the above sample code, I would then get the output along the lines (minus the headers etc):
<firstlevel>
<secondlevel>
<value1>1</value1>
<value2>2</value2>
</secondlevel>
</firstlevel>
The "section" could be a method, granted, but then how do I complement it with curly braces such that
section("firstlevel")
{
}
could replace
openSection("firstlevel");
.
.
closeSection();
where openSection/closeSection are defined something like (just rough pseudo code)
XmlWriterSettings settings = new XmlWriterSettings();
XmlWriter writer = XmlWriter.Create(SettingsFile, settings);
private void openSection(string sect)
{
writer.WriteStartElement(sect);
}
private void closeSection()
{
writer.WriteEndElement();
}
I hope this makes sense. There is no great loss if I cannot achieve what I am aiming for. But it would be really good if it could be achieved.
Thanks again,
David.
|
|
|
|
|
Sounds like you need a DSL, Domain Specific Language. The purpose of a DSL is to provide a language that models your business needs better than a general language like C#, if such a thing is needed. You can find more here:
Domain Specific Language @ Wikipedia
DSL in Visual Studio
|
|
|
|
|
Thanks for everyone's input. I might put this into the "Too hard basket" for the moment.
-David.
|
|
|
|
|
Hello everyone,
I am looking for a sample, which could let me deserialize an XML stream encoded in UTF-8 into a field of a class. More specifically, I have a class like,
class Foo
{
string abc;
byte[] bcd;
}
and abc maps to XML element "Abc" and bcd maps to XML element "Bcd", and I want to get the stream for bcd and retrieve bytes (from XML stream for related element "Bcd" directly) to manipulate manually/in a customized way.
I am looking for a sample, but failed, could anyone help to point me to a related sample or wrote some pseudo code?
thanks in advance,
George
|
|
|
|
|
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Soap;
[Serializable]
class Customer {
public string name;
public long id;
}
class Test{
static void Main(string[] args) {
ArrayList list = new ArrayList();
Customer cust = new Customer();
cust.name = "Charles Darwin";
cust.id = 10;
list.Add(cust);
cust = new Customer();
cust.name = "Isaac Newton";
cust.id = 20;
list.Add(cust);
foreach(Customer x in list){
Console.WriteLine("{0} : {1}", x.name.ToString(), x.id.ToString());
}
Console.WriteLine("Saving Customer list");
FileStream s = new FileStream("cust.txt", FileMode.Create);
SoapFormatter f = new SoapFormatter();
f.Serialize(s, list);
s.Close();
Console.WriteLine("Restoring to New List");
s = new FileStream("cust.txt", FileMode.Open);
ArrayList list2 = (ArrayList)f.Deserialize(s);
s.Close();
foreach(Customer y in list2){
Console.WriteLine(y.name + ":" + y.id);
}
}
}
//You have to reference in using System.Runtime.Serialization.Formatters.Soap;
//just right click on the reference folder and click add. Its under the web tab.
//Let me know if this helps
|
|
|
|