|
I think this can help u
u can use SqlDataAdapter and DataSet classes
SqlDataAdapter dd = new SqlDataAdapter();
DataSet de = new DataSet();
dd = new SqlDataAdapter("SELECT EmpName,isWaiter,isCashier FROM Employees", con);
de.Clear();
try
{
con.Open();
dd.Fill(de);
int k;
for (k = 0; k < de.Tables[0].Rows.Count; k++)
{
comboBox2.Items.Add(de.Tables[0].Rows[k].ItemArray[0].ToString());
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
|
|
|
|
|
using System.Data;
using System.Data.SqlClient;
Class test
{
public void pageload()
{
SqlConnection conn = new SqlConnection(@"User id:sa; Password:password; Initial catalog: databaseName; data source:localhost");
conn.Open();
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "SELECT bob FROM table";
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
dropdownlist.Items.Add(reader["bob"].ToString());
}
reader.Close();
conn.Close();
}
}
|
|
|
|
|
dear friends,
i am using WMI code to get print job details. i am not able to get number of copies which the user enterd for printing.
is there any way to get number of copies user entered. could any one help me. using c# or c++
thanks in advance
Nishar A.
|
|
|
|
|
Not reliably. The number of copies is no part of the job. An applicaiton has two choices when printing multiple copies. Either it can tell the driver to render the copies, in which case, the driver has a choice, whether to render the copies itself, or have the printer do it, or the application can render each copy itself, where the driver will never know there is multiple copies of the same page being generated.
|
|
|
|
|
Hi
i am basically new to C# ? and all this might be simple for you ppl ...
i wanna know how i can access or call a function of a form (say A ) from a Form (say B) .
I wanna create an application that has multiple forms in it .
Ur help will be highly appreciated
|
|
|
|
|
delegate is the way to go. FormB should expose a delegate on which FormA can subscribe to get notifications. Alternate way is to make the method public and pass first form's object to second form through constructor.
|
|
|
|
|
Hey budy ........... I used static Public variables then I used the NameofTheForm.Var_Name if I want to acces only variables . Does this work for functions
Thank you
|
|
|
|
|
That really is a bad idea for a number of reasons:
1) Consider the case when you have two forms open - which one can "load" the static variable? How would the accessor know which had loaded it?
2) Exposing variables directly as public fixes the design of your class - because something may use the public variable, you cannot change how your class works without reflecting that in the public variable. If you expose this as a property, you can.
3) Accessing a different forms data is a bad idea from the start, as it fixes the design of one form to teh design of another. This means it is much harder to reuse classes, and thus does nothing to improve reliablity.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
public static works, but is almost always the wrong way to do it. If any property or method is delaing with or getting data from an instance of the class it resides in, it should not be static. In these cases, you need an instance of the form to access its properties/methods. If you don't have an instance, then delegates/events are the way to go.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
|
I have been researching my issue with the reports. I have no idea what I am doing wrong. If someone is availiable to help me contact me on skype. My Skype Name is JollyMansArt.
I have been researching the development of reports both Crystal and Microsoft Report Viewer. I can not get the application to give me a report when I pass it information via a dataset, Only when I give the report the connection method directly. The problem with that is the database will be on different servers and different databases. So the report must pull it's data from the connection string.
With the crystal reports I go and create my report template positioning the fields, then I populate the dataset. But the report is always blank. The same goes for MS Report Viewer.
Why...
private void ReportSetup1()
{
SqlConnection conReport = new SqlConnection(WhatIsMyConnectionString);
SqlCommand cmdReport = new SqlCommand();
SqlDataReader drReport;
DataSet dsReport = new AppLoaderDataSet1();
try
{
conReport.Open();
cmdReport.CommandType = CommandType.Text;
cmdReport.Connection = conReport;
cmdReport.CommandText = "Select Domain, FullName, MachineName, WindowsUserName, ApplicationName, WorkstationVersion, ServerVersion from vw_Users_vs_Server_Versions_Match";
drReport = cmdReport.ExecuteReader();
dsReport.Tables[0].Load(drReport);
drReport.Close();
conReport.Close();
conReport.Open();
cmdReport.CommandType = CommandType.Text;
cmdReport.Connection = conReport;
cmdReport.CommandText = "Select Domain, FullName, MachineName, WindowsUserName, ApplicationName, WorkstationVersion, ServerVersion from vw_Users_vs_Server_Versions_NoMatch";
drReport = cmdReport.ExecuteReader();
dsReport.Tables[1].Load(drReport);
drReport.Close();
conReport.Close();
ADMCReportViewer.LocalReport.ReportEmbeddedResource = "PeerAssistLoader.UsersWithInvalidApplicationVersion.rdlc";
ReportDataSource rds = new ReportDataSource();
rds.Name = "AppLoaderDataSet1_vwUsersvsServerVersionsMatch";
rds.Value = dsReport.Tables[1];
ADMCReportViewer.LocalReport.DataSources.Add(rds);
ADMCReportViewer.RefreshReport();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
if (conReport.State == ConnectionState.Open)
{
conReport.Close();
}
}
}
|
|
|
|
|
Hi everyOne.
I have a DataGridView with a checkBoxCell(Column).I have 30 or...Rows in my dataGridView and i check 20 rows. I want to know how many rows is checked.
And how many is Not.
Thank u.
CanI
|
|
|
|
|
According to my calculations you have 20 checked, which leaves 10 unchecked.
Hope this helps!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Something like the following should suffice:
int checkedCount = 0;
foreach (DataGridRow row in this.myDataGridView)
{
if (row.Cells["nameOfYourColumn"].Value == true)
{
checkedCount++;
}
}
Sorry about the previous post, I couldn't resist!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi,
I have one field in database which is being updated by other process and this value is populated into the master page controls. I want to update this value on client browser as soon it is changed but I am running out of ideas.
any aproach to acomplish this would be highly apreciated.
Thanks in advance.
Regards
Prem.
|
|
|
|
|
If you are using SQL Server 2005 or 2008 have a look at SQL Notification Services, but be warned they can put a lot of load on the server.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
|
mobius111001 wrote: Does anyone know of any common errors
Yes, using an outdated version that can't handle the load.
mobius111001 wrote: or is it just possible I may be doing more work that this DB has ever seen??
Without knowing anything about the work are doing it is impossible to make that determination.
only two letters away from being an asset
|
|
|
|
|
Pretty much take a bunch of data from one table, saving it to a list in memory, going through the list, processing a record, and possibly writing data back to the db. It is being processed one record at a time.
|
|
|
|
|
Shouldn't be a problem. Maybe log file space/disk space/fragmentation?
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
hi all ,
this my codebehind on login button click
FormsAuthentication.Initialize();
FormsAuthenticationTicket ObjTicket = new FormsAuthenticationTicket(1, txtLoginId.Text, DateTime.Now, DateTime.Now.AddMinutes(60), false, txtLoginId.Text + "," + txtPassword.Text, FormsAuthentication.FormsCookiePath);
string encTicket = FormsAuthentication.Encrypt(ObjTicket);
string sLoginId = txtLoginId.Text;
sLoginId = sLoginId.Replace(" ", "");
Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));
Response.Redirect(FormsAuthentication.GetRedirectUrl(txtLoginId.Text, false)+"?id="+txtLoginId.Text);
and this is web config code
<authentication mode="Forms">
<forms defaultUrl="~/PresentationLayer/Forms/Main.aspx" loginUrl="~/Default.aspx" >
</forms>
</authentication>
above code well working on local host .......but on live host
"~/" append with url
for example i want
www.abc.com/abc/PresentationLayer/Forms/Main.aspx
but i get
www.abc.com/abc/~/PresentationLayer/Forms/Main.aspx
can anybody tell me that where is problem
|
|
|
|
|
|
I have been thinking of using crystal reports over Microsoft Report Viewer but both of them confuse me a little.
Here is why...
SQL Server already has the tables so in my logic of building reports in the past is I provide the following:
1) the sql connection string
2) The SQL Statement containing the fields names the report is wanting
3) Identify the report file
Then the report is generated.
But What I am noticing is I have to add an extra step I do not want to do. Which is creating a dataset.xsd file to have my sql statement load the data directly into.
What I want to know is how to build a report in a c# application that will use the applications connection string (because the database and or server will change names) and Allow me to pass a SQL statement directly into the report. What would be real nice is if I could have the report file external to the application so I can simply replace the report file when changes need done instead of having to recomplile the whole application, as well as dynamically call a report if the file exists and if not ignore the report.
|
|
|
|
|
JollyMansArt wrote: I am noticing is I have to add an extra step...Which is creating a dataset.xsd file
Why? Using the ReportViewer you just point to a SQL Reporting Service report, either local (rdlc) or remote (rdl). The data connection is in the report, no datasets involved.
only two letters away from being an asset
|
|
|
|
|
It is fine to have the data connection in the report but for both the crystal report and Microsoft report viewer I can not dynamically update or change the connection string to where the data is. As the application will be installed into another database and different server locations. So the applications connection string will become different than the reports connection string.
|
|
|
|