cmd = new OleDbCommand("select Convert(varchar(50),Fault_Time),[Level],[Trouble_Source],[Solution],[Ticket_Status],[Close_Date],convert(varchar,Close_Time),[Actual_Cause],[Solution],[Description] from [TT_Record$]", conn);


its showing error at runtime :- Undefined function 'Convert' in expression


pls suggest........

Recommended Answers

All 5 Replies

Try CStr() instead of Convert():

string query = "select CStr(Fault_Time),[Level],[Trouble_Source],[Solution]," +
    "[Ticket_Status],[Close_Date],CStr(Close_Time),[Actual_Cause],[Solution]," +
    "[Description] from [TT_Record$]";

cmd = new OleDbCommand(query, conn);

string query = "select CAST(Fault_Time AS varchar(50)) then remaining query "

hope this work.

string query = "select CAST(Fault_Time AS varchar(50)) then remaining query "

hope this work.

That's another alternative to try, but given that CONVERT() doesn't exist, I'd wager he's connected to a JET-SQL database. CAST() probably won't work any better.

Try CStr() instead of Convert():

string query = "select CStr(Fault_Time),[Level],[Trouble_Source],[Solution]," +
    "[Ticket_Status],[Close_Date],CStr(Close_Time),[Actual_Cause],[Solution]," +
    "[Description] from [TT_Record$]";

cmd = new OleDbCommand(query, conn);

its showing me thi error.....
Syntax error (missing operator) in query expression 'CStr[Fault_Time]'.

cmd = new OleDbCommand("select [uid],[Ticket_ID],[Name],[Title],CStr(Fault_Date),CStr(Fault_Time),[Level],[Trouble_Source],[Probable_Cause],[Affected_Site],[Description],[Solution],[Ticket_Status],CStr(Close_Date),Cstr(Close_Time),[Actual_Cause],[Solution],[Description],[SLA_Time],[SLA_Status] from [TT_Record$]", conn);


Error:-
The provider could not determine the String value. For example, the row was just created, the default for the String column was not available, and the consumer had not yet set a new String value

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.