名称'stringInfo'在当前上下文中不存在
本文关键字:上下文 不存在 stringInfo 名称 | 更新日期: 2023-09-27 18:02:57
public void Button_Click(object sender, RoutedEventArgs e)
{
string stringConnectionString = null;
SqlConnection objSqlConnection;
SqlCommand objSqlCommand = new SqlCommand();
DataSet objDataSet = new DataSet();
string stringCommandText = string.Empty;
stringConnectionString = ("Data Source=192.161.0.0;Initial Catalog=kkh_final;Persist Security Info=True;User ID=xx;Password=yyyyyyy");
objSqlConnection = new SqlConnection(stringConnectionString);
objSqlConnection.Open();
objSqlCommand.Connection = objSqlConnection;
objSqlCommand.CommandType = CommandType.StoredProcedure;
objSqlCommand.CommandText = "PCL0105A0_MR_Patients";
}
public void clsPatients(DataRow objDataRow, string[] stringInfo, string stringCommandText)
{
SqlParameter[] objSqlParameter;
stringCommandText = "PCL0105A0_MR_Patients";
int intRowIndex;
DataSet objDataSet = new DataSet();
SqlCommand objSqlCommand = new SqlCommand();
SqlDataAdapter objSqlDataAdapter;
try
{
objSqlParameter = new SqlParameter[63];
objSqlParameter[0] = new SqlParameter("@p_BO_ID", "KKHG");
objSqlParameter[0].Value = stringInfo[0];
objSqlParameter[1] = new SqlParameter("@p_HRN_ID", "A00025");
objSqlParameter[1].Value = objDataRow["HRN_ID"].ToString();
objSqlParameter[2] = new SqlParameter("@p_Short_Name", "Gowtham");
objSqlParameter[2].Value = objDataRow["Short_Name"].ToString();
objSqlParameter[3] = new SqlParameter("@p_Gender", "Male");
objSqlParameter[3].Value = objDataRow["Gender"].ToString();
objSqlParameter[4] = new SqlParameter("@p_DOB", "05/06/1992");
objSqlParameter[4].Value = objDataRow["DOB"].ToString();
objSqlParameter[5] = new SqlParameter("@p_Street_Name1", "Moovendar Nagar");
objSqlParameter[5].Value = objDataRow["Street_Name1"].ToString();
objSqlParameter[6] = new SqlParameter("@p_Ph_No1", "9585188641");
objSqlParameter[6].Value = objDataRow["Ph_No1"].ToString();
objSqlParameter[7] = new SqlParameter("@p_VIP_Status", "Yes");
objSqlParameter[7].Value = objDataRow["VIP_Status"].ToString();
objSqlParameter[8] = new SqlParameter("@p_Death_Status", "Will");
objSqlParameter[8].Value = objDataRow["Death_Status"].ToString();
objSqlParameter[9] = new SqlParameter("@p_Trans_Status", "test");
objSqlParameter[9].Value = objDataRow["Trans_Status"].ToString();
objSqlParameter[10] = new SqlParameter("@p_Citizenship", "Indian");
objSqlParameter[10].Value = objDataRow["Citizenship"].ToString();
objSqlParameter[11] = new SqlParameter("@p_Adm_Date", "05/06/1992");
objSqlParameter[11].Value = objDataRow["Adm_Date"].ToString();
objSqlParameter[12] = new SqlParameter("@p_Ref_Case", "NA");
objSqlParameter[12].Value = objDataRow["Ref_Case"].ToString();
objSqlParameter[13] = new SqlParameter("@p_Blk", "");
objSqlParameter[13].Value = objDataRow["Blk"].ToString();
objSqlParameter[14] = new SqlParameter("@p_Level_No", "25");
objSqlParameter[14].Value = objDataRow["Level_No"].ToString();
objSqlParameter[15] = new SqlParameter("@p_Unit_No", "25");
objSqlParameter[15].Value = objDataRow["Unit_No"].ToString();
objSqlParameter[16] = new SqlParameter("@p_Street_Name2", "Geetha Nagar");
objSqlParameter[16].Value = objDataRow["Street_Name2"].ToString();
objSqlParameter[17] = new SqlParameter("@p_City", "Thanjavoor City");
objSqlParameter[17].Value = objDataRow["City"].ToString();
objSqlParameter[18] = new SqlParameter("@p_Geographical_Area", "Thanjavoor");
objSqlParameter[18].Value = objDataRow["Geographical_Area"].ToString();
objSqlParameter[19] = new SqlParameter("@p_District", "Thanjavoor");
objSqlParameter[19].Value = objDataRow["District"].ToString();
objSqlParameter[20] = new SqlParameter("@p_Country", "India");
objSqlParameter[20].Value = objDataRow["Country"].ToString();
objSqlParameter[21] = new SqlParameter("@p_Post_Code", "636111");
objSqlParameter[21].Value = objDataRow["Post_Code"].ToString();
objSqlParameter[22] = new SqlParameter("@p_Ph_No2", "8792188641");
objSqlParameter[22].Value = objDataRow["Ph_No2"].ToString();
objSqlParameter[23] = new SqlParameter("@p_Ph_No3", "9626222891");
objSqlParameter[23].Value = objDataRow["Ph_No3"].ToString();
objSqlParameter[24] = new SqlParameter("@p_Ph_No4", "");
objSqlParameter[24].Value = objDataRow["Ph_No4"].ToString();
objSqlParameter[25] = new SqlParameter("@p_Ph_No5", "");
objSqlParameter[25].Value = objDataRow["Ph_No5"].ToString();
objSqlParameter[26] = new SqlParameter("@p_Ph_No6", "");
objSqlParameter[26].Value = objDataRow["Ph_No6"].ToString();
objSqlParameter[27] = new SqlParameter("@p_Email", "gtusk55@gmail.com");
objSqlParameter[27].Value = objDataRow["Email"].ToString();
objSqlParameter[28] = new SqlParameter("@p_Death_Date", "05/06/2085");
objSqlParameter[28].Value = objDataRow["Death_Date"].ToString();
objSqlParameter[29] = new SqlParameter("@p_Discharge_Disposition", "");
objSqlParameter[29].Value = objDataRow["Discharge_Disposition"].ToString();
objSqlParameter[30] = new SqlParameter("@p_Long_Name", "");
objSqlParameter[30].Value = objDataRow["Long_Name"].ToString();
objSqlParameter[31] = new SqlParameter("@p_Remarks", "");
objSqlParameter[31].Value = objDataRow["Remarks"].ToString();
objSqlParameter[47] = new SqlParameter("@p_delmark", "");
objSqlParameter[47].Value = objDataRow["delmark"].ToString();
objSqlParameter[48] = new SqlParameter("@p_gw_status", "");
objSqlParameter[48].Value = objDataRow["gw_status"].ToString();
objSqlParameter[49] = new SqlParameter("@p_data_source", "");
objSqlParameter[49].Value = objDataRow["data_source"].ToString();
objSqlParameter[50] = new SqlParameter("@p_Created_At", "");
objSqlParameter[50].Value = objDataRow["data_source"].ToString();
objSqlParameter[51] = new SqlParameter("@p_Created_By", "");
objSqlParameter[51].Value = objDataRow["data_source"].ToString();
objSqlParameter[52] = new SqlParameter("@p_Created_On", "");
objSqlParameter[52].Value = objDataRow["data_source"].ToString();
objSqlParameter[53] = new SqlParameter("@p_Modified_At", "");
objSqlParameter[53].Value = objDataRow["data_source"].ToString();
objSqlParameter[54] = new SqlParameter("@p_Modified_By", "");
objSqlParameter[54].Value = objDataRow["data_source"].ToString();
objSqlParameter[55] = new SqlParameter("@p_Modified_On", "");
objSqlParameter[55].Value = objDataRow["data_source"].ToString();
objSqlParameter[56] = new SqlParameter("@p_Temp_ID", "");
objSqlParameter[56].Value = objDataRow["Temp_ID"].ToString();
objSqlParameter[57] = new SqlParameter("@p_Temp_Flg", "");
objSqlParameter[57].Value = objDataRow["Temp_Flg"].ToString();
objSqlParameter[58] = new SqlParameter("@p_Latest_HRN", "");
objSqlParameter[58].Value = objDataRow["Latest_HRN"].ToString();
objSqlParameter[59] = new SqlParameter("@p_Latest_HRN", "");
objSqlParameter[59].Direction = ParameterDirection.Output;
// objSqlParameter[60] = new SqlParameter("@p_error_code", "");
//objSqlParameter[60].Direction = ParameterDirection.Output;
objSqlParameter[60] = new SqlParameter("@p_error_msg", "");
objSqlParameter[60].Direction = ParameterDirection.Output;
objSqlParameter[61] = new SqlParameter("@p_result", "");
objSqlParameter[61].Direction = ParameterDirection.Output;
objSqlParameter[62] = new SqlParameter("@p_data_source", "");
objSqlParameter[62].Direction = ParameterDirection.Input;
objSqlParameter[63] = new SqlParameter("@p_dml_indicator", "");
objSqlParameter[63].Value = objDataRow["dml_indicator"].ToString();
objSqlCommand.Parameters.AddRange(objSqlParameter);
objSqlDataAdapter = new SqlDataAdapter(objSqlCommand);
objSqlDataAdapter.Fill(objDataSet);
for (intRowIndex = 0; intRowIndex < objDataSet.Tables[0].Rows.Count - 1; intRowIndex++)
{
MessageBox.Show(objDataSet.Tables[0].Rows[intRowIndex][0].ToString());
}
}
这是我的代码,并尝试了很多,如果我解决一个错误,另一个会发生,这里是什么问题,我的代码?我做得对不对?
朋友我是这个代码字段的新手,所以帮助我
提前感谢朋友
好的,这里有一个如何创建连接,调用存储过程和填充数据集的示例,这是我认为您最终要实现的目标。显然,您需要根据您的数据对其进行调整,但希望这将使您顺利进行:
stringConnectionString = ("Data Source=192.161.0.0;Initial Catalog=kkh_final;Persist Security Info=True;User ID=xx;Password=yyyyyyy");
DataSet objDataSet = new DataSet();
using (SqlConnection connection = new SqlConnection(stringConnectionString))
{
SqlCommand cmd = new SqlCommand("dbo.MyProcedure", connection);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter pdParam = new SqlParameter("@YourParam", SqlDbType.VarChar);
pdParam.Value = pd;
cmd.Parameters.Add(pdParam);
SqlDataAdapter da = new SqlDataAdapter(cmd);
try
{
da.Fill(objDataSet);
}
catch (Exception ex)
{
string error = ex.Message;
}
}