urgent help needed - input string not in correct format

Z

ZZZ

this code :


try

{

DataSet dsDeurprijs = new DataSet();

SqlDataAdapter sqlDeurprijs = new SqlDataAdapter("Select
isnull(convert(varchar,promoprijsKK),'')as promoprijsKK from DEURPRIJZEN
where DEUR_KODE=" + sKode_deur,sqlConnection3);

sqlDeurprijs.Fill(dsDeurprijs);

int prijs =
Convert.ToInt32(dsDeurprijs.Tables[0].Rows[0].ItemArray[0].ToString());

MessageBox.Show(prijs.ToString());

}

catch(Exception ex)

{ MessageBox.Show(ex.Message.ToString());}



gives me : input string not in correct format



info :

promoprijsKK field = money

sKode_deur=string
 
M

MA

ZZZ said:
this code :


try

{

DataSet dsDeurprijs = new DataSet();

SqlDataAdapter sqlDeurprijs = new SqlDataAdapter("Select
isnull(convert(varchar,promoprijsKK),'')as promoprijsKK from DEURPRIJZEN
where DEUR_KODE=" + sKode_deur,sqlConnection3);

sqlDeurprijs.Fill(dsDeurprijs);

int prijs =
Convert.ToInt32(dsDeurprijs.Tables[0].Rows[0].ItemArray[0].ToString());

MessageBox.Show(prijs.ToString());

}

catch(Exception ex)

{ MessageBox.Show(ex.Message.ToString());}



gives me : input string not in correct format



info :

promoprijsKK field = money

sKode_deur=string
How doés the string looks like and how do you want it to look like?

/Marre
 
Z

ZZZ

select statement showed in messagebox is OK (tested in sql query analyzer)


dont know why this error is generated



MA said:
ZZZ said:
this code :


try

{

DataSet dsDeurprijs = new DataSet();

SqlDataAdapter sqlDeurprijs = new SqlDataAdapter("Select
isnull(convert(varchar,promoprijsKK),'')as promoprijsKK from DEURPRIJZEN
where DEUR_KODE=" + sKode_deur,sqlConnection3);

sqlDeurprijs.Fill(dsDeurprijs);

int prijs =
Convert.ToInt32(dsDeurprijs.Tables[0].Rows[0].ItemArray[0].ToString());

MessageBox.Show(prijs.ToString());

}

catch(Exception ex)

{ MessageBox.Show(ex.Message.ToString());}



gives me : input string not in correct format



info :

promoprijsKK field = money

sKode_deur=string
How doés the string looks like and how do you want it to look like?

/Marre
 
Z

Zürcher See

I don't understand why you, in your slect, convert the promoprijsKK field to
varchar, and then in Int32 in your code?

try
{
DataSet dsDeurprijs = new DataSet();
SqlDataAdapter sqlDeurprijs = new SqlDataAdapter("Select promoprijsKK
from DEURPRIJZEN where DEUR_KODE=" + sKode_deur,sqlConnection3);

sqlDeurprijs.Fill(dsDeurprijs);

if (dsDeurprijs.Tables[0].Rows[0][0]!=System.DbNull.Value)
{
int prijs =(int)dsDeurprijs.Tables[0].Rows[0][0];
MessageBox("prijs="+prijs);
}
else MessageBox("DbNullValue");
}
catch(System.Exception e)
{
MessageBox(e.Message);
}

ZZZ said:
this code :


try

{
SqlDataAdapter sqlDeurprijs = new SqlDataAdapter("Select
isnull(convert(varchar,promoprijsKK),'')as promoprijsKK from DEURPRIJZEN
where DEUR_KODE=" + sKode_deur,sqlConnection3);

sqlDeurprijs.Fill(dsDeurprijs);

int prijs =
Convert.ToInt32(dsDeurprijs.Tables[0].Rows[0].ItemArray[0].ToString());

MessageBox.Show(prijs.ToString());

}

catch(Exception ex)

{ MessageBox.Show(ex.Message.ToString());}



gives me : input string not in correct format



info :

promoprijsKK field = money

sKode_deur=string
 
Z

ZZZ

thx

this did it

string prijs = dsDeurprijs.Tables[0].Rows[0].ItemArray[0].ToString();



thx a lot!!!!!!!






Zürcher See said:
I don't understand why you, in your slect, convert the promoprijsKK field to
varchar, and then in Int32 in your code?

try
{
DataSet dsDeurprijs = new DataSet();
SqlDataAdapter sqlDeurprijs = new SqlDataAdapter("Select promoprijsKK
from DEURPRIJZEN where DEUR_KODE=" + sKode_deur,sqlConnection3);

sqlDeurprijs.Fill(dsDeurprijs);

if (dsDeurprijs.Tables[0].Rows[0][0]!=System.DbNull.Value)
{
int prijs =(int)dsDeurprijs.Tables[0].Rows[0][0];
MessageBox("prijs="+prijs);
}
else MessageBox("DbNullValue");
}
catch(System.Exception e)
{
MessageBox(e.Message);
}

ZZZ said:
this code :


try

{
SqlDataAdapter sqlDeurprijs = new SqlDataAdapter("Select
isnull(convert(varchar,promoprijsKK),'')as promoprijsKK from DEURPRIJZEN
where DEUR_KODE=" + sKode_deur,sqlConnection3);

sqlDeurprijs.Fill(dsDeurprijs);

int prijs =
Convert.ToInt32(dsDeurprijs.Tables[0].Rows[0].ItemArray[0].ToString());

MessageBox.Show(prijs.ToString());

}

catch(Exception ex)

{ MessageBox.Show(ex.Message.ToString());}



gives me : input string not in correct format



info :

promoprijsKK field = money

sKode_deur=string
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top