|
Loop through the strings in the array. Call Encoding.ASCII.GetBytes() for each element in the array.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
|
Lets say I have two forms (Form1 and Form2).
On Form1 there is a listbox that holds phone numbers.
On Form2 there is two textboxes where you enter a phonenumber and a description.
On Form1 you click a button and it opens Form2 to enter the information. So how do you take the information that is entered on Form2 and add it to the listbox on Form1?
|
|
|
|
|
There are several ways to do this. I'll give you the "easiest" (and least elegant):- Make the
Form1.myListBox member public.
- Pass a reference of the
Form1 instance to Form2 .
- In
Form2 's OnOKButtonClicked() handler, add the required entry to myListBox . /ravi
|
|
|
|
|
I'm still lost on this. I made listBox1 public.
Now how exactly am I going to do this? I need to transfer a textbox from Form2 back to Form1.
|
|
|
|
|
Jacob Dixon wrote: I need to transfer a textbox from Form2 back to Form1.
No. You need to copy data from one control (a textbox) to another (a listbox). For example:
theListBox.Items.Add (theTextBox.Text);
It seems you may have taken on a task that's (currently) a bit out of your reach. I recommend that you come up to speed on the basics of WinForms before continuing.
/ravi
|
|
|
|
|
Yea i know.. I haven't continued, but I'm ordering two books and going to read some more.
|
|
|
|
|
You can use Ravi's solution. However, that will make some data off your listbox, public.
I suggest to have Form2 with a property of type string,which gets and sets the data. in your case the set is mostly important. From Form1...you only need to set the property. From form2 just set the given value to the textbox.
I think its a little safer.
Regards
Kev.
|
|
|
|
|
Yea... uhmm I'm still a little confused... do you have an example or a website with a tutorial?
|
|
|
|
|
Hi Friends,
May be this will help you guys to help me .
I have in the form a textbox,a enter button and datagrid.
I want to enter data into my DB Table named "Self" on the click of button "Enter".
Till there its working fine.
Now on form load am trying to display the contents in my database (for simlicity i have only one coloumn in my database:"Name") in a datagrid.
The problem am facing is in writting that part of the code.
Shown below is my code.Please correct me.
private void Form1_Load(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection();
con.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\My Documents\Selftest.mdb";
OleDbCommand cmd = new OleDbCommand();
cmd.CommandText = "select * from Self";
cmd.Connection = con;
OleDbDataAdapter adap = new OleDbDataAdapter();
adap.SelectCommand = cmd;
DataSet ds = new DataSet();
adap.Fill(ds);
}
Now i will display my entire code if it might 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.Data.OleDb;
using System.Data.Odbc;
using System.IO;
namespace My_self_Test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection();
con.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\My Documents\Selftest.mdb";
con.Open();
OleDbCommand cmdObj = new OleDbCommand();
cmdObj.CommandText = "Insert into Self(Name) values ('" + txtName.Text + "')";
cmdObj.Connection = con;
cmdObj.ExecuteNonQuery();
}
private void txtDisplay_Click(object sender, EventArgs e)
{
}
private void gridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection();
con.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\My Documents\Selftest.mdb";
OleDbCommand cmd = new OleDbCommand();
cmd.CommandText = "select * from Self";
cmd.Connection = con;
OleDbDataAdapter adap = new OleDbDataAdapter();
adap.SelectCommand = cmd;
DataSet ds = new DataSet();
adap.Fill(ds);
}
}
}
Thanking you
|
|
|
|
|
I have written like this and this works:
dbConnetion1.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\db.mdb";
dbConnetion1.Open();
oleDbCommand1.CommandText = "select * from Name";
oleDbCommand1.CommandType = CommandType.Text;
oleDbCommand1.Connection = dbConnetion1;
oleDbCommand1.ExecuteNonQuery();
oleDbDataAdapter1.SelectCommand = oleDbCommand1;
DataTable table1 = new DataTable();
oleDbDataAdapter1.Fill(table1);
dataGridView1.DataSource = table1;
//or this one
DataSet dataset1 = new DataSet();
oleDbDataAdapter1.Fill(dataset1, "Name");
dataGridView2.DataSource = dataset1;
dataGridView2.DataMember = "Name";
dbConnetion1.Close();
Sourie
|
|
|
|
|
Thank You Sourie.
It works.
Thanks a lot
|
|
|
|
|
Welcome.
I have found a manual in this area. It is helpful.
If you want it please tell me: mansureh_shahraki@yahoo.com
Sourie
|
|
|
|
|
All,
I need to perform a Computer query in AD, but I am unsure how to authenicate myself.
A little background:
1). I am currently logged into a machine on the domain with my domain userID.
2). I have Admin rights to the Domain as it works perfectly with VBScript (without authentication), but not with C#.
I read that SetPrincipalPolicy() would allow you to authenticate yourself without providing a Username and password, but I have yet to find a way to use it successfully.
Does anyone have any ideas?
Thank you
|
|
|
|
|
|
Hi
i have days trying to create a method to work like "pack" method in php
some idea or guide to how? i'm tired
thanks
|
|
|
|
|
I am making a program that needs to be able to control at least 8 devices through relays. It has to be through a serial port. The computer will run 24/7 checking the time and then changing the state of the devices being controled when they are supposed to be turned off and on. The problem. I don't know how I would control these 8 different rellays through one serial port. I need help on giving all of the rellays a seperate address so I can change them independently.
Can anyone help me?
|
|
|
|
|
This question should be asked in the hardware forum, it is not C# specific.
If you insist on using a single serial port, you will need some electronic skills, since it
will require additional electronics organized around some microcontroller, which has a serial
port, at least 8 digital outputs, and some code (assembly, C) to listen to the serial port,
and execute incoming commands.
There probably are commercially available solutions that offer 8 outputs from a serial port,
I don't have any specific info tho. Google does.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- 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 PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Hello.. I am trying to create a new address book. I was wanting to know how to make it where you can create a new database and open existing databases to view. What I need to know is how to create a new database. I tried the source code from: http://support.microsoft.com/kb/307283
I keep getting that my sql server does not allow remote connections. It is locally though? Anyways I'm not asking anyone to write the code for me. If someone could refer me to a book that deals with C# and databases specially that would be much appreciated (or a website). I want to learn alot about databases and SQL. Thanks for the help in advance.
* EDIT *
By the website I meant one that explained each detail and how everything works. Thanks
|
|
|
|
|
Jacob Dixon wrote: sql server does not allow remote connections
By default it doesn't. You have to configure it through the Surface Area Configuration Manager ( or whatever it's called ) to allow "remote" connections.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Ohhh.. now that I think about it, I was checking out a program called Contact Keeper and it did the same thing I'm wanting to do except it used Microsoft Access instead of SQL. Would you recommend a book for C# that teaches pretty much nothing but databases in C#?
|
|
|
|
|
Jacob Dixon wrote: Would you recommend a book for C# that teaches pretty much nothing but databases in C#?
Look around on Amazon. I think there are books out there dedicated to C# and databases, just don't remember any particular titles.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
Ok thanks, I'll check them out. I'm also going to Barnes and Noble tomorrow so I will check there also.
|
|
|
|
|
I was going to mention Barnes and Noble. They do have a book, I think it is from Apress, that is titled something like C# and Databases, or some variation like that. Alot of the C#/Database articles on this site are winners, too.
"I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon
|
|
|
|
|
I actually have Professional C# 2005 with .NET 3.0 by Wrox. It has some information about databases, but I was looking for something that got in more detail. I like knowing how every command works and the fuctions. They have one that is Beginning C# 2005 Databases that I am fixing to go check out. Thanks for your help! Hopefully soon I'll be the one helping instead of getting help!
|
|
|
|