Solved

Cannot Implicitly Convert type 'int' to 'string' c# , sql server

Posted on 2011-09-20
2
370 Views
Last Modified: 2012-06-21
trying to insert sql statement by passing in parameters,
but one of the parameters datatype does not fit,

have checked that the datatype field in sql server are matched with the parameters datatype,
string strInsertStatus = InsertStudentAttendanceNTraineeModule(Convert.ToDateTime(dtSAC.Rows[0]["arrivedtime"]), Convert.ToDateTime(dtSAC.Rows[0]["actualtime"]),
                                Convert.ToDateTime(dtSAC.Rows[0]["leavetime"]), Convert.ToDateTime(dtSAC.Rows[0]["actualleavetime"]), dtSAC.Rows[0]["attendancestatus"].ToString(),
                                dtSAC.Rows[0]["lateduration"].ToString(), dtSAC.Rows[0]["earlierduration"].ToString(), dtSAC.Rows[0]["leavestatus"].ToString(), dtSAC.Rows[0]["absensereason"].ToString(),
                                Convert.ToInt64(dtTMC.Rows[0]["pid"]), Convert.ToInt64(dtTMC.Rows[0]["ctid"]), Convert.ToInt64(dtTMC.Rows[0]["mid"]), Convert.ToInt64(dtTMC.Rows[0]["lid"]),
                                Convert.ToInt64(dtTMC.Rows[0]["tid"]), Convert.ToInt64(dtTMC.Rows[0]["trid"]), Convert.ToInt64(dtTMC.Rows[0]["sid"]), Convert.ToInt64(dtTMC.Rows[0]["pid"]));



source from
-----------
                            select sa1.id as said, sa1.arrivedtime as arrivedtime, sa1.leavetime as leavetime, sa1.actualtime as actualtime, " + 
               "sa1.attendancestatus as attendancestatus, sa1.lateduration as lateduration, sa1.leavetime as leavetime, sa1.actualleavetime as actualleavetime, " + 
               "sa1.leavestatus as leavestatus, sa1.earlierduration as earlierduration, sa1.absensereason as absensereason, sa1.leaveearlierby as leaveearlierby from traineemodule tm " + 
                " JOIN StudentAttendanceC sa1 ON sa1.id = tm.said " + 
                " WHERE dateadd(month,(((Year(arrivedtime))-1900)*12)+Month(arrivedtime)-1,Day(arrivedtime)-1) = '" + strArrivedTime + "'";

Open in new window

TM tableSA table
0
Comment
Question by:doramail05
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 22

Accepted Solution

by:
pivar earned 500 total points
ID: 36565372
Hi,

How does your declaration for InsertStudentAttendanceNTraineeModule look like? It sounds as you are trying to use an int instead of a string as defined in the method.

/peter
0
 
LVL 1

Author Comment

by:doramail05
ID: 36565584
gosh,

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question