Please any one help me:
I run my application was created in C# for export data source t XML document, I also use try catch method for correct an error of database access (adapter.Fill(ds)). The problem is show below.
n_org:SELECTs_department.did,s_department.name,s_department.fk_deptFROMs_department
Index #0
Message: Incorrect syntax near ','.
LineNumber: 1
Source: .Net SqlClient Data Provider
Procedure:
Please give a suggestion or any correct code is ok.
Thanks
Your SELECT statement is all wrong - no spaces anywhere!
Instead of what you have right now:
SELECTs_department.did,s_department.name,s_department.fk_deptFROMs_department
use a statement that has the necessary spaces - like this:
SELECT s_department.did, s_department.name, s_department.fk_dept FROM s_department
Related
I know that you can get the data of a table in a SAP Server with the function RFCDestination.Repository.GetTableMetadata(string tablename). Unfortunately I get an error when I try to execute the command. The weird thing is when I give a exisiting table I get a different error when I try something random as a tablename.
Existing table:
var x = dest.Repository.GetTableMetadata("TFTIT");
Error:
SAP.Middleware.Connector.RfcInvalidStateException: "cannot find TABLE specified by TFTIT"
Random tablename:
var x = dest.Repository.GetTableMetadata("Test123");
Error:
SAP.Middleware.Connector.RfcInvalidStateException: "metadata for TableOnly TEST123 not available: NOT_FOUND: No active nametab exists for TEST123"
I know there is a way to get the data of a table with the help of a function module but I need to use the GetTableMetadata function.
One cannot do so much wrong when calling RfcRepository.GetTableMetadata(string). Does your used user ID has the required RFC authorizations for repository queries as listed in SAP note 460089 (scenario 3)? If yes, this is maybe a bug in the NCo3 library or even in the ABAP backend. Do you use NCo's latest patch level? This is currently NCo 3.0.20.
If not, try updating the library first.
Otherwise I recommend to create an SAP support ticket for the first error message. The second error is normal when the specified table name does not exist.
Alternatively you may also try what happens if calling RfcRepository.GetStructureMetadata(string) for this table instead. The meta data for tables and structures is quite similar and the same remote function modules are used for the DDIC queries. Maybe this works. However, I think in the first place RfcRepository.GetTableMetadata(string) should work here.
I hope this helps.
Hey guys I am almost done with my CRUD project for my Database Project. I am just trying to finish up and complete the Delete Functionality.
query = string.Format("DELETE FROM customers WHERE `cid`= {0};", mDeleteTextBox);
My variable mDeleteTextBox is filled with the value I want.
What is wrong with my query?
ERROR MESSAGE
An unhandled exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll
Additional information: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.TextBox, Text: 6' at line 1
Your additional information says it all: you're trying to pass mTextBox as a parameter for your query, but in order to access the content of the textbox itself (which is the data you want to use to complete your query), you should access the Text property of the textbox.
So, your code:
query = string.Format("DELETE FROM customers WHERE `cid`= {0};", mDeleteTextBox);
became
query = string.Format("DELETE FROM customers WHERE `cid`= {0};", mDeleteTextBox.Text);
I'm reading a tab delimited text file into a String[]. Then, go thru the array line by line, split it into individual elements (currentLine.Split('\t')), make changes to the elements as needed, and then do a Parameters.Add to add each element as a parameter to the query string.
For the most part, it works and has added stuff to the Access table. However, it hit something in the data that it didn't like, and I'm having trouble determining which element is causing the data mismatch. The only error I'm getting (VS Express 2012) is Data type mismatch in criteria expression.
Is there a way to see which parameter is causing the error? I can tell which line it is by looking at what's already been added to the table, but I don't see where the problem is.
Thanks!
Your question seems pretty general although here are some techniques that will help you resolve it:
Wrap your database insert/update statement in a try / catch. Within the catch block write the parameters that were active at time of the insert.
Inspect the exception for an inner exception that will likely have more specific details of the invalid parameter/value.
I'm doing a project in Asp .Net and C#. I'm also using ODP .NET to connect to my Oracle DB.
I am using a stored procedure to insert a value into the database. Everything is fine, it also raises all the exceptions I have.
I have 3 exceptions:
when the value I try to insert already exists in the database
when i try to insert a null value
Default "Others"
When the first two exceptions are raised I insert the error into a table Errors, everything goes well.
What I really want to know is, how can I show a message to the user when a Exception occurs?
Something like dbms_output.put_line("Error");...but I want it to show in my webpage. Is this possible?
Any tips are welcome, thanks in advance.
Since your .NET program is your client, you should let any unhandled exceptions propagate from your PL/SQL program and back to the client, where you can deal with it like any other exception.
In other words, you should remove the "when others" exception from your PL/SQL code, and instead wrap your database call (using ODP.NET) with a C# exception block. There you can catch the exception and get the Oracle error number and text, and display it to the user if you want.
(Using this approach you can also use RAISE_APPLICATION_ERROR in your PL/SQL code to signal errors back to the C# client.)
You can fix the stored procedure to return an integer, 0 means ok, 1 means exception of type 1, 2 exception of type 2 and so on... in this way the UI can notify the user that saving method did not go well as expected.
Normally I would not have handled the exception in the stored procedure but I understand that you want to log the error from SQL so the above way should allow you to do what you want.
In our sql server stored procedures we have something like this:
IF ##ERROR <> 0
return (1)
ELSE
return (0)
but it depends on what the stored does and what else it returns, if the stored returns a table, you can then use output parameter to send back the integer discussed above.
i am using windows forms application with MSAccess.... i got data from database table successfully but when i am trying to add data with (') character i got the exception that "OLEDB Exception: Syntax error(Missing Operator)inquery expression" ... Now how can i solve this problem? Plz tell me the solution of this problem....
all characters are accepted but apostrophe character only got error...
Thanks in Advance
This is not realted to MsAccess - the ' is a string delimiter in SQL.
Look at the SQL satement you submit to the database and you will find out it may look something like
SELECT FROM Users WHERE NAME LIKE 'mc'donald'
and
'mc'donald'
has a ' too much.
You need to escape those ('mc''donald') OR - better - use parameters.
Also read up on SQL Injection Attacks - the basics there tell you a lot about how to properly deal with databases.