?
Solved

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

Posted on 2011-09-20
2
Medium Priority
?
381 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 2000 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

Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

Question has a verified solution.

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

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

762 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