|
try this:
<br />
if(ofd.ShowDialog() == DialogResult.OK)<br />
{<br />
textBox.text = "FileName: " + ofd.FileName;<br />
}<br />
|
|
|
|
|
Hi
here is my code i conver the excel file in to sql server 2005 i want to write a logc for excel data to cerate a pivot table for specific coloumbs
I want help regarding the SQL query
namespace WindowsApplication2
{ public partial class Form1 : Form
{
DataTable dtbl;
private SqlCommand scmd;
public Form1()
{
InitializeComponent();
scmd = new SqlCommand();
}
private void button1_Click(object sender, EventArgs e)
{
string filename = @"C:\abc.xls";
String connectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + filename + ";" +
"Extended Properties=Excel 8.0;";
OleDbConnection connection = new OleDbConnection(connectionString);
connection.Open();
OleDbCommand selectCommand = new OleDbCommand("SELECT * FROM [sheet1$]", connection);
OleDbDataAdapter dataAdapter = new OleDbDataAdapter();
dataAdapter.SelectCommand = selectCommand;
DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet);
dtaTable dataTable = dataSet.Tables[0];
dataGridView1.DataSource = dataSet.Tables[0];
MessageBox.Show(dataGridView1.RowCount.ToString());
connection.Close();
}
private void Form1_Load(object sender, EventArgs e)
{
string constr = "server=Myserver,database=mor,uid=;pwd=;";
SqlConnection sqcon = new SqlConnection(constr);
string cnd = "Select * from emp";
}
private void button2_Click(object sender, EventArgs e)
{
string constr="data source=Myserver;initial catalog=mo;integrated security=SSPI";
SqlConnection sqcon = new SqlConnection(constr);
sqcon.Open();
int i = 1;
while (i < (dataGridView1.Rows.Count)-2)
{
string istr = "insert into emp(name,std,des)values('" + Convert.ToString(dataGridView1.Rows[i].Cells[9].Value.ToString()) + "','" + Convert.ToString(dataGridView1.Rows[i].Cells[10].Value.ToString()) + "','" +Convert.ToString(dataGridView1.Rows[i].Cells[17].Value.ToString()) + "')";
scmd.CommandText = istr;
scmd.Connection = sqcon;
int r;
r = scmd.ExecuteNonQuery();
i++;
}
if (i > 1)
{
MessageBox.Show("Records saved");
}
}}}
|
|
|
|
|
what is the problem you are having, asking for unspecified help is not going to get you anything.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
hi,
i want to open only excel file using OpenFileDialog box need help.
here is my code which open any file from local drive.
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
openFileDialog1.ShowDialog();
System.Diagnostics.Process.Start(openFileDialog1.FileName, "Fileselected");
}
|
|
|
|
|
Apply filter to OpenFileDialog
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Excel|*.xls";
ofd.ShowDialog();
System.Diagnostics.Process.Start(ofd.FileName, "Fileselected");
|
|
|
|
|
is there any method to get entiered file string in text box from OpenFileDialog box
|
|
|
|
|
No, only the full path. You can use Path.GetFileName to get the filename without the path in front of it
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
How to config the strong name for wrapper assebmly key file in project properties
|
|
|
|
|
I am trying to use an OLE Automation Server object intended for VB6 in a c# project.
The documentation that comes say to do the following:
Dim PHD as Object
Set PHD = CreateObject("VisualPHD.Data")
I've added the object to my project as a reference and try to use
Type phd = Type.GetType("VisualPHD.Data");
This returns null. If I look in the Object Browser, I see that there is an interface called "PHDCtrl". Using that as the parameter to GetType, I still get null.
How do I determine the type I should be passing to GetType, or should I be doing something different altogether?
Once I get the type, I should be able to do something like:
PHDCTRLLib.PHDCtrl PHD = (PHDCTRLLib.PHDCtrl)Activator.CreateInstance(phd);
Here is a link to the info from Object Browser: http://i43.tinypic.com/2hpkv3s.jpg[^]
Any help on what I should pass to GetType?
Thanks
modified 12-Jul-20 21:01pm.
|
|
|
|
|
First of all, I do not see VisualPHD.Data in the object browser. I am assuming that you want to create an instance of PHDCtrlLib.PHDCtrl. Try this:
PHDCtrl PHD = new PHDCtrlClass();
The PHDCtrlClass implements the PHDCtrl interface.
|
|
|
|
|
I've tried that approach and I end up with a "catastrophic failure" error. I've decided to bite the bullet and try and get .NET components from the vender.
Thank you
modified 12-Jul-20 21:01pm.
|
|
|
|
|
Did you ever have any luck with getting VisualPHD.Data to work with C#?
|
|
|
|
|
Yes, well, indirectly.
I created an intermediate library in C++ that interfaced with the uniformance dll (not the VisualPHD one) and translated the old-style structures into sane data structures that were easy to marshall. Then I wrote a C# library to interface with my C++ library and the known data structures to get data from PHD.
Unfortunately I don't have any code to share because I moved on from that job.
modified 12-Jul-20 21:01pm.
|
|
|
|
|
how can you check programmatically whether it's debug/release version of your project?
thanks
dev
|
|
|
|
|
#if DEBUG
#else
#endif
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
you can interrogate the DEBUG preprocessor
private bool IsDebugMode()
{
#if DEBUG
return true;
#else
return false;
#endif
}
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
|
Hi as above, would appreciate for the help! thanks!
|
|
|
|
|
Sure - why not ? The only thing is that i'm not sure if 2005 included it's own web server, and so for ASP.NET, you may be stuck, b/c Vista Home Basic doesn't have one.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hello,
When i make this in c# console application :
<br />
Thread thread = new Thread(new ParameterizedThreadStart(SendEmail));<br />
thread.Start(mail_message);
i have an error on line : Thread thread = new Thread(new ParameterizedThreadStart(SendEmail));
Erreur 1 An object reference is required for the nonstatic field, method, or property 'Ab.Program.SendEmail(object)' D:\PROJETS\Ab\Program.cs 301 64 Ab
Please help me to resolve this problem, thank you verry mutch.
|
|
|
|
|
SendEmail is short for this.SendEmail however this does not exist inside a static method; that is what the message said.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
thank you verry mutch, how i can resolve this in c# console application?? when i put this.SendEmai the error was ; keyword 'this' is not valid in static propriety, but in win form application it work!! please help me thank you verry mutch.
|
|
|
|
|
The above code was in the Main() method of the console application, right?
You have to make the SendEmai method static;
|
|
|
|
|
How i can make this? thank tou verry mutch
|
|
|
|
|
In your code, you should have something like public void SendEmail , change in public static void SendEmail
|
|
|
|