|
csanda1 wrote: Id like source code to do that
Well this is not nice to say around here. Tell us what you tried, and what it's not working and then you'll get some help.
I will use Google before asking dumb questions
|
|
|
|
|
Your problem might be the databinding...see where it's done...Maybe we could help you better if you would post some of your code.
I will use Google before asking dumb questions
|
|
|
|
|
Sorry for being vague.This is the code in form 2
<br />
private void button1_Click(object sender, EventArgs e)<br />
{<br />
string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=datatry.mdb";<br />
string Company = txtSearch.Text;<br />
string select = "SELECT * FROM ecmain WHERE CompanyName Like '" + Company + "'";<br />
OleDbConnection datatryConn = new OleDbConnection(strConnection);<br />
datatryConn.Open();<br />
<br />
OleDbDataAdapter da = new OleDbDataAdapter(select, datatryConn);<br />
DataSet ds = new DataSet();<br />
<br />
da.Fill(ds, "ecmain");<br />
<br />
update frm = new update(txtSearch.Text );<br />
frm.Show();<br />
<br />
datatryConn.Close(); <br />
code in form 2
<br />
private void btnUpdate_Click(object sender, EventArgs e)<br />
{<br />
<br />
string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=datatry.mdb";<br />
<br />
string select = "Update ecmain SET CompanyName ='" + txtCompany.Text + "' , ContactName ='" + txtName.Text + "',ContactSurname='" + txtSurname.Text + "', Designation='" + txtDesignation.Text + "',TelephoneNumber='" + txtTel.Text + "', Faxnumber= '" + txtFax.Text + "', Email='" + txtEmail.Text + "',City/Town='" + txtCity.Text + "',PostCode='" + txtPost.Text + "',NumberofEmployees='" + txtEmployees.Text + "', Export='" + cbxExport.SelectedItem + "',ExportDestinations='" + txtDestination.Text + "', SIC Product 1='" + txtSic1.Text + "', Product1_Description='" + txtProduct1.Text + "', SICProduct2='" + txtSic2.Text + "', Product2Description='" + txtProduct2.Text + "', SICProduct3='" + txtSic3.Text + "', Product3Description='" + txtProduct3.Text + "', GeneralComments='" + txtComment.Text + "', Complete='" + cbxComplete.SelectedItem + "' Where CompanyName='" + txtSearch.Text + "'";<br />
OleDbConnection datatryConn = new OleDbConnection(strConnection);<br />
OleDbCommand cmd = new OleDbCommand(select, datatryConn);<br />
<br />
datatryConn.Open();<br />
cmd.ExecuteNonQuery();<br />
datatryConn.Close();<br />
MessageBox.Show("Updated successfully!");<br />
}<br />
Easy guys im new to programming
csanda
|
|
|
|
|
where is button1 and btnUpdate? You wrote that the whole code is placed in the second form...you got me confused.
I will use Google before asking dumb questions
|
|
|
|
|
Ok its like this.Form1 has txtsearch and button1 for search.When u type the company name in the textbox and click the button it shows the update form.
This code is in form1
private void button1_Click(object sender, EventArgs e)
{
string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=datatry.mdb";
string Company = txtSearch.Text;
string select = "SELECT * FROM ecmain WHERE CompanyName Like '" + Company + "'";
OleDbConnection datatryConn = new OleDbConnection(strConnection);
datatryConn.Open();
OleDbDataAdapter da = new OleDbDataAdapter(select, datatryConn);
DataSet ds = new DataSet();
da.Fill(ds, "ecmain");
update frm = new update(txtSearch.Text );
frm.Show();
datatryConn.Close();
Form2 is named update, it has a datagridview and textboxes, now what i need is when I click button1 in form1 the search results to appear in the datagridview in form2
This is the update code in form 2
private void btnUpdate_Click(object sender, EventArgs e)
{
string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=datatry.mdb";
string select = "Update ecmain SET CompanyName ='" + txtCompany.Text + "' , ContactName ='" + txtName.Text + "',ContactSurname='" + txtSurname.Text + "', Designation='" + txtDesignation.Text + "',TelephoneNumber='" + txtTel.Text + "', Faxnumber= '" + txtFax.Text + "', Email='" + txtEmail.Text + "',City/Town='" + txtCity.Text + "',PostCode='" + txtPost.Text + "',NumberofEmployees='" + txtEmployees.Text + "', Export='" + cbxExport.SelectedItem + "',ExportDestinations='" + txtDestination.Text + "', SIC Product 1='" + txtSic1.Text + "', Product1_Description='" + txtProduct1.Text + "', SICProduct2='" + txtSic2.Text + "', Product2Description='" + txtProduct2.Text + "', SICProduct3='" + txtSic3.Text + "', Product3Description='" + txtProduct3.Text + "', GeneralComments='" + txtComment.Text + "', Complete='" + cbxComplete.SelectedItem + "' Where CompanyName='" + txtSearch.Text + "'";
OleDbConnection datatryConn = new OleDbConnection(strConnection);
OleDbCommand cmd = new OleDbCommand(select, datatryConn);
datatryConn.Open();
cmd.ExecuteNonQuery();
datatryConn.Close();
MessageBox.Show("Updated successfully!");
}
csanda
|
|
|
|
|
You can create a public method in the second form, let's say BindData(). After you call the second's form constructor in button1_Click event, you call that method before showing the second form. Like this:
update frm = new update(txtSearch.Text );
frm.BindData();
frm.Show();
Make sure that the BindData method is the one that binds the gridview and the textboxes to the database according with the text the form received in it's constructor.
Hope it helps.
I will use Google before asking dumb questions
|
|
|
|
|
Please don't have direct queries like this. It's just bad practice. Instead, take a look at using Command Parameters - they are your friend, and they remove a lot of vulnerabilities from your application (take a look at this[^] article). Also take a look at this[^] article on passing values between forms.
|
|
|
|
|
Tell me how much you can owe me?. I will take up that task.
Once you have mastered the ability to turn yourself invisible at will, and to deflect bullets with your hair, you will be ready to come back here to the lounge and post programming questions.Only at this point will you be able to dodge the fireballs that are going to come your way. - Pete O'Hanlon
|
|
|
|
|
If your forms are modeless, then in form2, add a string property, in form1, after the user has changed text in the text box, change that property on form2.
if your form2 is modal, then add the string from the text box as a parameter to the constructor of form2.
|
|
|
|
|
Ill owe u big time. Pliz help
|
|
|
|
|
I have just helped - what I described are fairly fundamental features of the C# language, so you if you don't understand that, I'd suggest you find yourself a good book on the subject
|
|
|
|
|
select the datagrid and right click it a pop up menu will displayed inside that u will find Choose Data Source inside that u give the database name and the table name it will automatically displays the datas that are binded inside the table on the page load itself....
|
|
|
|
|
hi,
i have got a class like this in my windows form project.I wanna change ranges horizantalaligment to left?
class ExcelAktar
{
private Excel.Application Excelim;
private Excel.Workbook CalismaKitabi;
private Excel.Worksheet CalismaSayfasi;
public void OkuVeYaz(DataGridView DisDataGrid, string CalismaSayfasiIsmi)
{
//DisDataGrid.AllowUserToAddRows = false;
Excelim = new Excel.ApplicationClass();
object SalakObje = System.Reflection.Missing.Value;
CalismaKitabi = Excelim.Workbooks.Add(SalakObje);
CalismaSayfasi = (Excel.Worksheet)CalismaKitabi.ActiveSheet;
CalismaSayfasi.Name = CalismaSayfasiIsmi;
int SutunIndex = 1;
int SatirIndex = 2;
// Sütunlar Yazılıyor.
foreach (DataGridViewColumn Sutun in DisDataGrid.Columns)
{
CalismaSayfasi.Cells[1, SutunIndex] = Sutun.HeaderText;
SutunIndex++;
}
// Satırlar Yazılıyor.
foreach (DataGridViewRow Satir in DisDataGrid.Rows)
{
for (int ci = 0; ci < DisDataGrid.Columns.Count; ci++)
{
CalismaSayfasi.Cells[SatirIndex, ci + 1] = Satir.Cells[ci].Value.ToString();
}
SatirIndex++;
}
// Excel gösteriliyor
Excelim.Visible = true;
// Biçimlendirme
CalismaSayfasi.get_Range("A1", "J1").EntireColumn.AutoFit();
CalismaSayfasi.get_Range("A1", "J1").Font.Bold = true;
CalismaSayfasi.get_Range("A1", "J1").EntireColumn.Font.Size= 7;
CalismaSayfasi.get_Range("A1", "J1").HorizontalAlignment = 2;
CalismaSayfasi.get_Range("A1", "J1").RowHeight = 16;
|
|
|
|
|
Hi,
how to make the generic type has specific constructor?
what should I add on the class definition if I don't want to add get/set function to set that value for some reason?
e.g.
public class ClassA<T>
{
public T Create()
{
List list = outside.list();
T t = new T(list);
}
}
// how to let T is only has a T(List list)? I have thing about Interface and Abstract class but those cannot work. And if I tried to use another class to input the value, it's too specific. any solution?
Thanks.
|
|
|
|
|
Hi all,
How can I achieve the same pop out like window, that Visual Studio 2005 uses.
Can anyone please provide me some information whether this is possible or not.
Many Thanks
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
Iam having an HTML file where in iam writing some text and it has some background image embedded in it.i want to convert that html file to image file and want to export it in pdf format.(without converting to image file,the image is not exported.)can anyone tell me how to convert an html image file into pdf format using c# coding.it is very urgent.please
pintoo
|
|
|
|
|
|
chithra.r wrote: it is very urgent.please
Please don't say this. It's rude. Besides, it can't be that urgent otherwise you would be paying someone for assistance, right?
There's nothing built into the .NET framework for creating PDF files. You will have to use a third-party component. Search the web for more information.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hi,
I've got a query which looks similar to this: "...FROM xy WHERE ID=@Id AND NAME IN (@Names)". I want to pass multiple parameters for @Names, so that it would be like:
"...AND NAME IN ('Susi', 'Peter', 'Steven')"
Is this anyhow possible with the use of parameters? Is could form a qry like that in the code with building up the string, but I would prefer the way with parameters.
The problem is that when I setup @Names to be AnsiString or String (Varchar) then it builds something like this: N'Susi, Peter, Steven'. That's one long String so it searches in the DB like the following: "... NAME IN('Susi, Peter, Steven') - which of course, doesn't exist.
Any ideas? Impossible?
Thx, Shi
|
|
|
|
|
TheShihan wrote: I've got a query which looks similar to this: "...FROM xy WHERE ID=@Id AND NAME IN (@Names)". I want to pass multiple parameters for @Names, so that it would be like:
"...AND NAME IN ('Susi', 'Peter', 'Steven')"
Don't know exactly, try this
FROM xy WHERE ID=@Id AND NAME IN (@Name1,@Name2,@Name3) add parameters for all these.
|
|
|
|
|
the problem is, that you don't know in advance, how many parameters are passed. It's dynamic.
|
|
|
|
|
TheShihan wrote: I've got a query which looks similar to this: "...FROM xy WHERE ID=@Id AND NAME IN (@Names)".
I don't think you can do this.
One way you could do this without dynamically constructing a SQL statement to execute is to split your comma-separated list and load the items into a table variable. You can then JOIN your table xy to your table variable to find the records in this table where the name is in the list.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
TheShihan wrote: to pass multiple parameters for @Names
Something like this[^]
Once you have mastered the ability to turn yourself invisible at will, and to deflect bullets with your hair, you will be ready to come back here to the lounge and post programming questions.Only at this point will you be able to dodge the fireballs that are going to come your way. - Pete O'Hanlon
|
|
|
|
|
ho to add right-click to a "Console" object ?
thanks
|
|
|
|
|
You cant.
xacc.ideIronScheme a R5RS-compliant Scheme on the DLR
The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach."
|
|
|
|
|