Click here to Skip to main content
15,887,331 members
Home / Discussions / C#
   

C#

 
AnswerRe: Universal Patch Finder .NET plug-ins Pin
Pete O'Hanlon6-Dec-12 23:01
mvePete O'Hanlon6-Dec-12 23:01 
AnswerRe: Universal Patch Finder .NET plug-ins Pin
Paul Conrad7-Dec-12 8:08
professionalPaul Conrad7-Dec-12 8:08 
GeneralRe: Universal Patch Finder .NET plug-ins Pin
Hypercube Softwares2-Mar-13 5:51
Hypercube Softwares2-Mar-13 5:51 
GeneralRe: Universal Patch Finder .NET plug-ins Pin
Paul Conrad2-Mar-13 7:19
professionalPaul Conrad2-Mar-13 7:19 
GeneralRe: Universal Patch Finder .NET plug-ins Pin
Hypercube Softwares2-Mar-13 7:27
Hypercube Softwares2-Mar-13 7:27 
GeneralRe: Universal Patch Finder .NET plug-ins Pin
Hypercube Softwares3-Mar-13 8:35
Hypercube Softwares3-Mar-13 8:35 
AnswerRe: Universal Patch Finder .NET plug-ins Pin
Mycroft Holmes12-Aug-14 0:36
professionalMycroft Holmes12-Aug-14 0:36 
QuestionC#.Net error(Front end Visual studio 2010,Back end:SQL server 2008)-) Pin
S Akshay6-Dec-12 17:03
S Akshay6-Dec-12 17:03 
View visit link is given on Registration form, when user will click that link, it is showing following MessageBox 3 times:
Index was out of range.Must be non-negative and less than the size of the collection.
Parameter name:Index
After clicking ‘OK’ button on this MessageBox 3 times it will show The data in DataGridView as follows:
Also it is showing that MessageBox again.

Following is the blank OPD visit Form through which user can fill particular OPD visit details:

When user will click on any row of DataGridView(which is showing OPD visits) from ‘View visit’ form,
it has to show particular OPD visit details on ‘OPD visit’ form given above.
But now problem is that many times I have to click on any row of DataGridView showing OPD /IPD visits.
And when I click on any row of DataGridView showing IPD visits then it shows the error:
Object reference not set to instance of an object.
After clicking on ‘Ok’ it shows result.
SqlConnection con = new SqlConnection("Data Source=AKSHAY-PC;Initial Catalog=Paranjpe_Hospital;User ID=sa;Password=akshay;Pooling=False");
try
{
con.Open();
// string sqlqry = "select distinct PRN,OPD_Visit_No,OPD_visit_Date from OPD_visit where PRN= '" + PRN + "'"; original query
SqlCommand cmd = new SqlCommand("View_OPD_visits", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@PRN", PRN); //Convert.ToInt32(PRN));
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
//DataTable dt = new DataTable();
//DataTable dt = new DataTable();
//dt.Columns.Add("PRN");
//dt.Columns.Add("OPD_Visit_No");
//dt.Columns.Add("OPD_visit_Date");
//dt.Columns.Add("OPD_subcase");
//dt.Columns.Add("Diagnosis");
//dt.Columns.Add("obs_LMP");
//dt.Columns.Add("obs_EDD");
//dt.Columns.Add("Remark");
//dt.Columns.Add("Abnormal_findings");


//select PRN,OPD_Visit_No as Visit_No,OPD_visit_Date as Visit_Date,OPD_subcase as subcase,Diagnosis,obs_LMP as LMP,obs_EDD as EDD,Remark,Abnormal_findings from OPD_visit
da.Fill(ds); //, "OPD_visit");
//da.Fill(ds);
//BindingSource bSource = new BindingSource();
if (ds.Tables[0].Rows.Count > 0)
{
dataGridView_view_OPD_visits.Refresh();
dataGridView_view_OPD_visits.DataSource = ds.Tables[0];//ds.Tables[0];
//dataGridView_view_OPD_visits.DataBindings.Add(dt);
//dataGridView_view_OPD_visits.DataBind();
//dataGridView_view_OPD_visits.DataBindings.ToString();
//dataGridView_view_OPD_visits.BindingContext[ds.Tables[0], "OPD_visit"];//,"OPD_visit"];
}
/*


Datagridview.DataSource = < THE DATA SOURCE>
DataTable dt = new DataTable();

dt.Columns.Add("Name");

dt.Columns.Add("Age");

dt.Columns.Add("Salary");



for (int i = 1; i <= 10; i++)

dt.Rows.Add(

string.Concat("Name", i)

, i + 10

, i * 2000

);



dgView.DataSource = dt;

*/
//bSource.DataSource = ds;
//dataGridView_view_OPD_visits.AutoGenerateColumns = true;
//dataGridView_view_OPD_visits.Refresh();
//dataGridView_view_OPD_visits.DataSource = bSource;//ds.Tables["OPD_visit"]; //"OPD_visit"]; //.Tables["OPD_visit"]; //.Tables[0];
//dataGridView_view_OPD_visits.DataBindings.Add(ds);
/*
DataGridView dgView = new DataGridView();

//BindingSource to sync DataTable and DataGridView
BindingSource bSource = new BindingSource();

//set the BindingSource DataSource
bSource.DataSource = dTable;

//set the DataGridView DataSource
dgView.DataSource = bSource;
*/



//dataGridView_view_OPD_visits.AutoGenerateColumns = true;
//dataGridView_view_OPD_visits.DataSource = ds.Tables[0];

//dataGridView_view_OPD_visits.DataBindings=dt; //.Tables[0];
//dataGridView_view_OPD_visits.DataMember = "OPD_visit";

/*
use like this :-
gridview1.DataSource = ds.Tables[0]; <-- Use index or your table name which you want to bind
gridview1.DataBind();
*/
}
catch (Exception exception)
{
MessageBox.Show(exception.Message);
}
finally
{
con.Close();
}

SqlConnection con1 = new SqlConnection("Data Source=AKSHAY-PC;Initial Catalog=Paranjpe_Hospital;User ID=sa;Password=akshay;Pooling=False");
try
{
con1.Open();
// string sqlqry = "select distinct PRN,OPD_Visit_No,OPD_visit_Date from OPD_visit where PRN= '" + PRN + "'"; original query
SqlCommand cmd = new SqlCommand("View_IPD_visits", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@PRN", Convert.ToInt32(PRN));
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);//, "IPD_visit");
//if (dataGridView_View_IPD_visits.RowCount == 0)
//{
// break;
//}
//BindingSource bSource = new BindingSource();
//bSource.DataSource = ds;
dataGridView_View_IPD_visits.Refresh();

// dataGridView_View_IPD_visits.DataSource = ds.Tables[0];
//dataGridView_View_IPD_visits.AutoGenerateColumns = true;
dataGridView_View_IPD_visits.DataSource = ds.Tables[0]; //bSource;//ds.Tables[0];//"IPD_visit"];//.Tables["IPD_visit"];
//dataGridView_View_IPD_visits.DataMember = "IPD_visit";
}
catch (Exception exception)
{
MessageBox.Show(exception.Message);
}
finally
{
con1.Close();
}
private void dataGridView_view_OPD_visits_RowEnter(object sender, DataGridViewCellEventArgs e)
{
try
{
int prn_view_visits = 0;
int OPD_visit_no_view_visits = 0;
prn_view_visits = Convert.ToInt32(dataGridView_view_OPD_visits.SelectedRows[0].Cells[0].Value);
OPD_visit_no_view_visits = Convert.ToInt32(dataGridView_view_OPD_visits.SelectedRows[0].Cells[1].Value);
OPD_visit ov = new OPD_visit(prn_view_visits, OPD_visit_no_view_visits);
ov.txtBx_PRN.Text = prn_view_visits.ToString();
ov.txtBx_OPD_visit_no.Text = OPD_visit_no_view_visits.ToString();
ov.txtBx_patient_name.Text = P_name;
ov.Show();
}
catch (Exception exception)
{
MessageBox.Show(exception.Message);
}
finally
{
//con.Close();
}

//SqlConnection con = new SqlConnection("Data Source=AKSHAY-PC;Initial Catalog=Paranjpe_Hospital;User ID=sa;Password=akshay;Pooling=False");
//try
//{
// con.Open();
// // string sqlqry = "select distinct PRN,OPD_Visit_No,OPD_visit_Date from OPD_visit where PRN= '" + PRN + "'"; original query
// SqlCommand cmd = new SqlCommand("Patient_Select_by_PRN", con);
// cmd.CommandType = CommandType.StoredProcedure;
// cmd.Parameters.AddWithValue("@PRN",prn_view_visits);
// SqlDataAdapter da = new SqlDataAdapter(cmd);
// DataSet ds = new DataSet();
// ds.Clear();
// da.Fill(ds);
// if (ds.Tables[0].Rows.Count > 0)
// {
// ov.txtBx_patient_name.Text = ds.Tables[0].Rows[0][1].ToString();
// }
// else
// {
// MessageBox.Show("Patient is not registered!");
// }
//}


}

private void dataGridView_View_IPD_visits_RowEnter(object sender, DataGridViewCellEventArgs e)
{
try
{
int prn_view_visits = 0;
int IPD_visit_no_view_visits = 0;
prn_view_visits = Convert.ToInt32(dataGridView_view_OPD_visits.SelectedRows[0].Cells[0].Value);
IPD_visit_no_view_visits = Convert.ToInt32(dataGridView_view_OPD_visits.SelectedRows[0].Cells[1].Value);
IPD_visit iv = new IPD_visit(prn_view_visits, IPD_visit_no_view_visits);
iv.txtBx_PRN.Text = prn_view_visits.ToString();
iv.txtBx_IPd_visit_no.Text = IPD_visit_no_view_visits.ToString();
iv.textBox_IPD_patient_name.Text = P_name;
iv.Show();
}

catch (Exception exception)
{
MessageBox.Show(exception.Message);
}
finally
{
//con.Close();
}
}


Please tell me solution of the problem.
AnswerRe: C#.Net error(Front end Visual studio 2010,Back end:SQL server 2008)-) Pin
lukeer6-Dec-12 20:50
lukeer6-Dec-12 20:50 
AnswerRe: C#.Net error(Front end Visual studio 2010,Back end:SQL server 2008)-) Pin
Mycroft Holmes6-Dec-12 21:51
professionalMycroft Holmes6-Dec-12 21:51 
AnswerRe: C#.Net error(Front end Visual studio 2010,Back end:SQL server 2008)-) Pin
Simon_Whale6-Dec-12 22:54
Simon_Whale6-Dec-12 22:54 
QuestionRecursive data object and Tree View WPF Pin
radkrish6-Dec-12 13:38
radkrish6-Dec-12 13:38 
QuestionColorDialog. Pin
Septimus Hedgehog6-Dec-12 11:22
Septimus Hedgehog6-Dec-12 11:22 
AnswerRe: ColorDialog. Pin
Brisingr Aerowing7-Dec-12 17:12
professionalBrisingr Aerowing7-Dec-12 17:12 
GeneralRe: ColorDialog. Pin
Septimus Hedgehog8-Dec-12 0:05
Septimus Hedgehog8-Dec-12 0:05 
GeneralRe: ColorDialog. Pin
Brisingr Aerowing8-Dec-12 7:35
professionalBrisingr Aerowing8-Dec-12 7:35 
GeneralRe: ColorDialog. Pin
Septimus Hedgehog8-Dec-12 9:27
Septimus Hedgehog8-Dec-12 9:27 
GeneralRe: ColorDialog. Pin
Brisingr Aerowing8-Dec-12 12:46
professionalBrisingr Aerowing8-Dec-12 12:46 
GeneralRe: ColorDialog. Pin
Septimus Hedgehog8-Dec-12 22:09
Septimus Hedgehog8-Dec-12 22:09 
GeneralRe: ColorDialog. Pin
Brisingr Aerowing9-Dec-12 5:52
professionalBrisingr Aerowing9-Dec-12 5:52 
GeneralRe: ColorDialog. Pin
Septimus Hedgehog9-Dec-12 21:35
Septimus Hedgehog9-Dec-12 21:35 
GeneralRe: ColorDialog. Pin
Brisingr Aerowing10-Dec-12 6:10
professionalBrisingr Aerowing10-Dec-12 6:10 
GeneralRe: ColorDialog. Pin
Brisingr Aerowing10-Dec-12 6:15
professionalBrisingr Aerowing10-Dec-12 6:15 
GeneralRe: ColorDialog. Pin
Septimus Hedgehog10-Dec-12 6:21
Septimus Hedgehog10-Dec-12 6:21 
GeneralRe: ColorDialog. Pin
Brisingr Aerowing10-Dec-12 9:16
professionalBrisingr Aerowing10-Dec-12 9:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.