|
How i cam hide menu dynamically
|
|
|
|
|
You didn't notice that we have an ASP.NET forum ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
HI
here is my code i take 1 txt,1datagride,2 button,1 file dialog box .
on 1 button i open filedialog box select 1 excel file and fetch string in to txt box,and try to open this excel file in datagride view
WHEN I RUN MY PROGRAM A RUN TIME EXCEPTION THROWEN BY OLEDB IE,
Cannot update. Database or object is read-only.
error occures at connection.Open();
my excel file close when program running.
PLZ HELP
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Data.OleDb;
namespace filedialog
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
private void button2_Click(object sender, EventArgs e)
{
string filename = @"textBox1.Text";
String connectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + filename + ";" +
"Extended Properties=Excel 8.0;";
OleDbConnection connection = new OleDbConnection(connectionString);
connection.Open();
//String connectionString="Provider=Microsoft.Jet.OLEDB.4.0;"+"Data Source="+filename +";"+"Extended Properties=Excel 8.0;";
OleDbCommand selectCommand = new OleDbCommand("SELECT * FROM [sheet1$]", connection);
OleDbDataAdapter dataAdapter = new OleDbDataAdapter();
dataAdapter.SelectCommand = selectCommand;
DataSet dataSet = new DataSet();
dataAdapter.Fill(dataSet);
// double sum = 0.0;
// We'll make some assumptions for brevity of the code.
System.Data.DataTable dataTable = dataSet.Tables[0];
dataGridView1.DataSource = dataSet.Tables[0];
MessageBox.Show(dataGridView1.RowCount.ToString());
connection.Close();
//openFileDialog1.ShowDialog();
//openFileDialog1.ShowDialog();
// return sum;
// directorySearcher1.FindAll();
}
private void button3_Click(object sender, EventArgs e)
{
OpenFileDialog FD = new OpenFileDialog();
FD .Filter="Excel|*.xls";
if (FD.ShowDialog() == DialogResult.OK)
{
textBox1.Text = " " + FD.FileName;
}
}
}
}
|
|
|
|
|
Are you trying to open the file that you are providing from Text Box??
if you are doing so then,
string filename = @"textBox1.Text";
this statement is wrong you should not precede with @ here,which means take the followed string as it is! In your case filename is takes as "textBox1.Text" which is not the file which you want to access.......
so change your line by removing @ symbol and qoutes.....
so your this line should be like this
string filename = textBox1.Text;
which will give you the file name provided in the testbox
hope this will work for you............
Happy coding!!!!!!
Deep
|
|
|
|
|
|
Hi,
The MMC SnapIn I'm developing has configuration data that has to be committed by the user.
So if the user has made some changes, but not yet committed the changes, how can you catch the fact that the MMC console is trying to exit, and allow the user the option to stop it exiting so they can commit the changes?
The SnapInBase class has an OnShutdown override method, but in the docs for this, it says that you must not bring up a modal dialog while it is being called. It's also not clear how to abort the exit from within this call.
Any help would be appreciated.
Peter
|
|
|
|
|
Hi all
I want to change ipdaddress on pda, which connected activesync
ip address "192.168.55.101" gateway "192.168.55.100"
I use IOCTL_NDIS_GET_ADAPTER_NAMES and IOCTL_NDIS_GET_ADAPTER_BINDINGS
but that name is "PPTP"
how to change ipaddress at activesync ?
|
|
|
|
|
Hi
I am building a windows Form application where the Forms names are stored in a data table as text , The name of the Form selected to run is retrieved from the data table , so it will be a string type , how can I call the related form knowing its name as a string only ?
Any Ideas ?
|
|
|
|
|
Via Reflection. Search the articles here for "plug-ins" and "add-ons" and "dynamic loading" and such.
|
|
|
|
|
use reflection,you can find the guideline about using this from msdn or google,it's quite easy..
|
|
|
|
|
I have an array with 4 elements in each record of 8 records, the first element is a string, the other 3 are int. How do I pull the 3 elements, i.e., 98, 97, 98 from the record, then add them together? Thanks
|
|
|
|
|
You could use a LINQ query to that for you. Without knowing your actual data structure it would be difficult to provide a sample query.
|
|
|
|
|
create a class
public class array_of_4element()
{
public array_of_4element(string s, params int[] i)
{
str = s;
num.CopyTo(i,0);
}
string str;
int[] num = new int[3];
public int sum()
{
return num[0]+num[1]+num[2];
}
}
so your
onetreeup wrote: an array with 4 elements in each record of 8 records
would be done in
<code>List<array_of_4element> 8_records = new List<array_of_4element>(8);
array_of_4element arr = new array_of_4element("text1", 98,97,98);
8_records.Add(arr);
8_records[0].sum();
</code>
8.Kelvin()
{
while (!(the machine can program itself))
Wont_stop_coding = true;
}
modified on Monday, March 23, 2009 12:24 AM
|
|
|
|
|
Has anyone written the code to draw two dimensional pictures to display Nautilus spirals? That would save me a lot of time if I don't have to re-invent it for myself! ( Or am I just lazy!!)
Wej Parry
|
|
|
|
|
Is a Nautilus spiral where someone hammers nails into a board and runs string so it makes a curve ? If so, that's pretty trivial, about 10 minutes work. Where are you stuck ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
The Nautilus spiral gets its name from the Nautilus sea shell and it is one of natures wonderful implementations of the Fibonacci numbers rule.If you look at http://www2.umassd.edu/temath/HomePageContent.html you will see a good example.
I could not complete the necessary C# code in 10 minutes as I am quite new to C#. So I was hoping that someone had already done it ( no point in reinventing the wheel) and I would learn from any such example.
Wej
Wej Parry
|
|
|
|
|
I want to learn how to use a local (stored on the computer not the internet) database to store information for my application. I did some searching and found articles, but they seemed to have no relation to a learning sequence.
I have C# programming experience but no database experience, where should I start and what articles should I read?
Thanks.
|
|
|
|
|
You need to learn SQL first. Once you've done that, you can write a database, and then you can connect to it, and learn how to execute SQL and deal with the results. I'd buy a SQL book and read it, first.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Yeah, I'd suggest a book, can't recommend any though.
|
|
|
|
|
install a mssql,then use it,it's better to practice,
|
|
|
|
|
if you read ADO.Net for comprehensively than automatically u will learn SQL
|
|
|
|
|
Is there a way to find the difference between the two. I see in ADSI EDIT there is a group type, but is that it?
Here is my code which gets ALL the groups.. Which by the way, this works TONS faster than using the AccountManagement from 3.5 way.
Here is the code to get the groups from a single user:
RegistryAccess reg = new RegistryAccess();
PrincipalContext adPrincipalContext;
if (reg.LDAPauth) adPrincipalContext = new PrincipalContext(ContextType.Domain, reg.LDAPpath, reg.LDAPusername, reg.LDAPpassword);
else adPrincipalContext = new PrincipalContext(ContextType.Domain, reg.LDAPpath);
UserPrincipal user = UserPrincipal.FindByIdentity(adPrincipalContext, this.UserName);
PrincipalSearchResult<Principal> results = user.GetAuthorizationGroups();
foreach (Principal result in results)
{
AddListBoxCurrent(result.Name);
}
Now that only returns like 5 for a single user, but using this to get ALL of the groups is faster.. i mean it finishes populating the entire AD groups before populating the listbox with the groups for jsut that user:
try
{
using (DirectoryEntry root = new DirectoryEntry())
{
RegistryAccess reg = new RegistryAccess();
root.Path = "LDAP://" + reg.LDAPpath;
if (reg.LDAPauth)
{
root.Username = reg.LDAPusername;
root.Password = reg.LDAPpassword;
}
using (DirectorySearcher searcher = new DirectorySearcher())
{
searcher.SearchRoot = root;
searcher.SearchScope = SearchScope.Subtree;
searcher.Filter = "(ObjectCategory=group)";
searcher.PropertiesToLoad.Add("name");
searcher.PropertiesToLoad.Add("grouptype");
SearchResultCollection results = searcher.FindAll();
if (results != null)
{
int count = results.Count;
foreach (SearchResult result in results)
{
ResultPropertyCollection props = result.Properties;
foreach (string propName in result.Properties.PropertyNames)
{
if (propName == "name") AddListBoxAvail(props[propName][0].ToString());
}
}
}
searcher.Dispose();
root.Close();
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
So my first question is, how do I just get security groups, then just get distribution groups. What I am trying to do is populate a listbox on the left that "The user belongs to" and populate a listbox on the right that has "available security groups". So you can click a button to add or remove groups to that user. But how do I just get "Security groups" for this part, then I'll have another part for Distribution groups?
|
|
|
|
|
hi,
i have a program that receiving inforamtion from a port (SerialPort object).
i am reading the port's information(Stream) from another object by StreamReader like this:
SerialPort port=new SerialPort(.....);
port.NewLine= "\r";
StreamReader sr=new StreamReader(port.BaseStream);
while reading the the stream to the end:
while (!sr.endOfFile)
{
line= sr.readLine();
}
this Method stucks on the last line on the stream.it reads all the Stream except the last line.
But after adding information (Strings) to the stream (from the port).. it continues reading the last line with the new information...
do you know how to solve it?
thank you..
P.S
Maybe..is it something with the sr.NewLine argument?
|
|
|
|
|
Try sr.ReadLine != null in while loop condition.
जय हिंद
|
|
|
|
|
it stucks on readLine. i mean, the processor arrives to this line (line= sr.readline()) and just stop.
even if i add another line to while:
while(!sr.endOffile)
{
line= sr.readline(); <------------it stops here------
messageBox.show("Just string"); the processor do not arrive to this line
}
the processor stops working even if the Stream is not endOfFile. Why?!
P.S
i changed !sr.endofFile to line!=null it is still not working...
|
|
|
|