Solved

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

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
sqlseverexpress 2008 agent xps question 1 11
Hide Tab Page 3 19
Iterate two lists and remove inactive 11 28
sql query Help 12 29
In this article I will describe the Detach & Attach 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.
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

705 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

13 Experts available now in Live!

Get 1:1 Help Now