私はCup_INSFuneralHome「プロシージャまたは関数を探して 『解析およびDBへの負荷のテキストファイルC#を使用してストアドプロシージャ
の継続的なエラーに問題を抱えているが供給されなかった@funeralhomename『』パラメータを期待します』 。
私は数多くの変更を行いましたが、何も効果がありませんので、私は間違った場所を探していたことを考慮する必要があります。
私がデバッグしているとき、正しい情報を正しい順序で取得しているようです。私はこの上のかなりこだわっている
会社名
アドレス
市状態郵便番号
電話
:として、元のテキストファイルがフォーマットされています。私は他の投稿を見てきましたが、私が必要とするものを見つけることができなかった、または、「いくらか」類似の投稿の多数から必要なものを抽出することができませんでした。問題は私の目の前に座っているのではないかと思うが、私はそれを見ることはできない。私は目の新鮮なセットが必要です。だから私は事前に謝罪します。
のprocコード:
ALTER procedure [dbo].[Cup_INSFuneralHome]
@funeralhomename nvarchar(50),
@addressone nvarchar(50),
@addresstwo nvarchar(50),
@CityName nvarchar(50),
@State nvarchar(10),
@Zipcode nchar(10),
@Telephone nchar(15),
@PrimaryContact nvarchar (50),
@EmailAddress nvarchar (50)
as
declare @cityid uniqueidentifier
declare @stateid uniqueidentifier
select @cityid = (select cityid from [city] where CityName=(@CityName))
select @stateid = (select stateid from [State] where StateCode=ltrim(rtrim(@State)))
insert funeralhome(funeralhomename, addressone, addresstwo, cityid, stateid, zipcode, telephone, PrimaryContact, EmailAddress)
values (@funeralhomename, @addressone, @addresstwo, @CityName, @State, @ZipCode, @Telephone, @PrimaryContact, @EmailAddress)
C#コード:
namespace abc
{
class Program
{
static void Main(string[] args)
{
address myclass = new address();
string dbConnection = "xyz";
string path = "D:\\docs\\someDocument.txt";
StreamReader sr = new StreamReader(path);
int intcount=0;
string sLine = "";
ArrayList fhome = new ArrayList();
ArrayList Ads = new ArrayList();
while (sLine != null)
{
sLine = sr.ReadLine();
if (sLine != null)
fhome.Add(sLine);
intcount=intcount+1;
}
sr.Close();
int startcount=0;
for (int n = 0; n < fhome.Count; n++)
{
char[] delim = {',', ' '};
try
{
if (startcount == 0)
{
myclass = new address();
}
if (fhome[n].ToString().Trim().Length > 0)
{
if (!fhome[n].ToString().Contains("Funeral Home Profile"))
{
switch (startcount)
{
case 0:
myclass.company = fhome[n].ToString().Trim();
startcount = startcount + 1;
break;
case 1:
myclass.address1 = fhome[n].ToString().Trim();
startcount = startcount + 1;
break;
case 2:
myclass.address2 = fhome[n].ToString().Trim();
startcount = startcount + 1;
break;
case 3:
myclass.telephone = fhome[n].ToString().Trim();
startcount = 0;
Ads.Add(myclass);
break;
}
}
}
}
catch { }
}
SqlConnection conn = new SqlConnection(dbConnection);
for(int n=0;n< Ads.Count;n++)
{
address tclass = (address)Ads[n];
int comloc;
comloc = tclass.address2.IndexOf(",");
string funeralhomename = tclass.company.ToString();
string street = tclass.address1.ToString();
string street2 = "";
string city = tclass.address2.Substring(0, comloc);
string state = tclass.address2.Substring(comloc + 1, 3);
string zip = tclass.address2.Substring(comloc + 4);
string tel = tclass.telephone.Replace("Local:", "");
string PrimaryContact = "";
string EmailAddress = "";
string tsql = "";
tsql = (funeralhomename + ',' +
street + ',' + street2 + city + ',' +
state + zip + tel + PrimaryContact + EmailAddress);
conn.Open();
try
{
SqlCommand cmd = new SqlCommand("Cup_INSFuneralHome", conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter[] param = new SqlParameter[9];
param[0] = new SqlParameter("@funeralhomename", SqlDbType.NVarChar);
param[0].Value = funeralhomename;
param[1] = new SqlParameter("@addressone", SqlDbType.NVarChar);
param[1].Value = street;
param[2] = new SqlParameter("@addresstwo", SqlDbType.NVarChar);
param[2].Value = street2;
param[3] = new SqlParameter("@cityname", SqlDbType.NVarChar);
param[3].Value = city;
param[4] = new SqlParameter("@State", SqlDbType.NVarChar);
param[4].Value = state;
param[5] = new SqlParameter("@zipCode", SqlDbType.NChar);
param[5].Value = zip;
param[6] = new SqlParameter("@Telephone", SqlDbType.NChar);
param[6].Value = tel;
param[7] = new SqlParameter("@PrimaryContact", SqlDbType.NVarChar);
param[7].Value = PrimaryContact;
param[8] = new SqlParameter("@EmailAddress", SqlDbType.NVarChar);
param[8].Value = EmailAddress;
cmd.ExecuteNonQuery();
}
catch
{
Debug.Print("Error with.." + tclass.company);
}
finally
{
conn.Close();
}
Debug.Print(tsql);
}
}
}
}
public class address
{
private string _company;
private string _address1;
private string _address2;
private string _telephone;
public string company
{
get { return _company; }
set { _company = value; }
}
public string address1
{
get { return _address1; }
set { _address1 = value; }
}
public string address2
{
get { return _address2; }
set { _address2 = value; }
}
public string telephone
{
get { return _telephone; }
set { _telephone = value; }
}
}
cityidとstateidはuniqueidentifierですか?怒っていますか??あなたは何州や都市を期待していますか? –
葬儀場は「クライアント」および/または墓地の都市と州に基づいています –
ありがとうございました、私は必要な変更を実装しましたが、今は「文字列からユニークな識別子 '。私もprocを変更して、データを取得するためにUIDを削除しましたが、エラーは続きます –