Solved

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

Posted on 2011-09-20
2
358 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
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now