I'm currently working on an ASP.NET MVC web application. I used this tutorial to use MySqlMembershipProvider in the app. The required tables are also created in the MySql database:
Now, when I try to register as a new user in my application, I get this error:
Unknown column 'Extent1.UserName' in 'field list'
Exception Details: MySql.Data.MySqlClient.MySqlException: Unknown column 'Extent1.UserName' in 'field list'
Source Error:
Line 80: {
Line 81: var user = new ApplicationUser() { UserName = model.UserName };
//error comes here at line 82
Line 82: var result = await UserManager.CreateAsync(user, model.Password);
Line 83: if (result.Succeeded)
Line 84: {
The error message shows that a query is being run which expects a field that it cannot find. So, the first thing to check is whether your my_aspnet_users table contains a UserName field. If not, then some error has occurred when the table was created.
If the field does exist, check your membership connection string and make sure it is connecting to the right database.
Related
I have a package with a bunch of oledb Destinations, using SSIS 2016 - which is supposed to show the exact column that generated the error.The ErrorColumn shows (0) zero, therefore I am unable to trap the column that generated the error.
Using the script below (with code that assigns "Unknown column" but it does not help, it just avoids the script fail):
public override void Input0_ProcessInputRow(Input0Buffer Row)
{
//IDTSComponentMetaData130 componentMetaData = ComponentMetaData as IDTSComponentMetaData130;
//var component130 = this.ComponentMetaData as IDTSComponentMetaData130;
//if (component130 != null)
//{
// System.Windows.Forms.MessageBox.Show(component130.GetIdentificationStringByID(Row.ErrorColumn));
// Row.ErrorColumnName = component130.GetIdentificationStringByID(Row.ErrorColumn);
//}
IDTSComponentMetaData130 componentMetaData = ComponentMetaData as IDTSComponentMetaData130;
if (componentMetaData != null)
{
//
if (Row.wkpErrorColumn != 0)
Row.wkpErrorColumnName = componentMetaData.GetIdentificationStringByID(Row.wkpErrorColumn);
else
Row.wkpErrorColumnName = "Unknown column";
}
else
{
Row.wkpErrorColumnName = "Cannot determine";
}
Row.wkpErrorDescription = ComponentMetaData.GetErrorDescription(Row.wkpErrorCode);
}
In SSIS 2008 (and I believe also SSIS 2016), a zero error column identifies an error that affects the entire row. In the example below, I have created a package that contains only 1 data flow task in the control flow and redirecting all errors and truncations to the error output. Placed a row count task just to have somewhere to send them to.
Also placed data viewers in both error flows to see the data coming out of it.
In a package consuming data from a flat file into an OLE DB Destination:
Using these values as input data
And having name as the PK of the table
We get a PK violation, check the error description and the error column
So when the error affects the entire record, it gets an error column value of 0.
Hope this helps.
I found that
When the error is generated by the PK, the error affect the entire row, and the error column is 0
When the error is generated by a Fk, The error affect only the column, and you get the error column value different then 0
I'm currently developing a program that connects to various external APIs for transactions.
The APIs returns a JSON that I want to store completely in a MySQL database column. I don't want to create a column for every data returned as that means I'll have to create different rows for every different JSON response, and that's not scalable.
I also want to keep them stored as JSON as they would be easy to process in a query and in code. So in my database I have a table where I store the external transaction info and an external_extra column where I want to store the JSON Object.ยด
My code
connection.acquire(function(err, con) {
console.log('inserting: ' + [transactionId, externalReference,
externalTransactionStatus, externalExtra]);
con.query('insert into external_transaction (transaction, external_reference, status,' +
'external_extra) ' +
'values (?,?,?,?)', [transactionId, externalReference,
externalTransactionStatus, externalExtra],
function(err, result) {
con.release();
if(err) console.log(err);
cb(result.insertId);
});
Where externalExtra is the JSON received from the API. Running that code gives me an error as it uses the JSON to add more fields to the insert instead of inserting the json. Example: if the json has a structure like:
{
type: 'internal_transaction',
address: 'rDLwhx2M9YfbNfZWDq5opJMttQjh7xtvh5',
sequence: 42,
id: 98,
specification: 'created with rrDL55JshyMtlIU sequence'
}
I get the error: Error:
ER_BAD_FIELD_ERROR: Unknown column 'type' in 'field list' as it takes 'type' as a column for the table.
Any help on this would be appreciated.
I don't know much about mySql, but had a similar error using a postgresSql database, this seems to be some kind of parsing error, why not try to parse the json object to string doing JSON.stringify(externalExtra)
I'm working on web application using JSP. it is almost done. However, I'm facing a weird issue while using update command. I tried in all ways but no luck.
Below is the error message:
**HTTP Status 500 -
type Exception report
message
The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 ''desc'='<h1 style="text-align: center;">
cv cfv sdfbgdfbg</h1>', sub_by='SP526' at line 1
root cause
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 ''desc'='<h1 style="text-align: center;">
cv cfv sdfbgdfbg</h1>', sub_by='SP526' at line 1
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.0.1 logs.
GlassFish Server Open Source Edition 3.0.1**
My Code is as below :
*<%
String sr=request.getParameter("kt");
String title=request.getParameter("kt1").trim();
// out.println("title"+title);
String d=request.getParameter("kt2").trim();
// out.println("description"+d);
String assignee=request.getParameter("kt3");
// out.println("Assignee"+assignee);
java.sql.Timestamp sqlNow=new java.sql.Timestamp(new java.util.Date().getTime());
// out.println("date"+sqlNow);
try{
Class.forName("com.mysql.jdbc.Driver");
}
catch (Exception e)
{
out.println("<script> alert('Something went wrong')</script>");
}
java.sql.Connection el=DriverManager.getConnection("jdbc:mysql://localhost/kt","root","");
Statement ed=el.createStatement();
String aa="update add_kt set title='"+title+"', desc='"+d+"', sub_by='"+assignee+"', Last_mod='"+sqlNow+"' where sr='"+sr+"' ";
ed.executeUpdate(aa);
out.println("<script> alert('Data has been updated')</script>");
out.println("<a href='admin_page.jsp'>Go to Previous Page</href>");
%>*
After clicked on submit button its encountered "Error HTTP Status 500".
Use preparedStatement instead of createStatement. Hence, your code will looks like this.
String query = "update add_kt set title=?, desc=?, sub_by=?, Last_mod=? where sr=?;<br>
PreparedStatement pst = el.prepareStatement(query);<br>
pst.setString(1,title);<br>
pst.setString(2,d);<br>
pst.setString(3,assignee);<br>
pst.setString(4,sql_now);<br>
pst.setString(5,sr);<br>
pst.executeUpdate();
PS: Always use PrepareStatement when u have complex query builder concatenation.
INSERT INTO voucher (voucher_no, account, party_name, rece_amt, particulars, voucher_date, voucher_type, cuid, cdt)
SELECT voucher_rec_no, #account, #party_name, #rece_amt, #particulars, #voucher_date, #voucher_type, #cuid, #cdt
FROM auto_number
WHERE (auto_no = 1)
Error:
A parameter is not allowed in this location. Ensure that the '#' sign is in a valid location or that parameters are valid at all in this SQL statement.
I've just stumbled upon this whilst trying to fix the same issue. I know it's late but, assuming that you're getting this error when attempting to execute the query via .net, ensure that you are setting the SqlCeParameter.DbType - if this is not specified, you get the exception you listed above.
Example (assume cmd is a SqlCeCommand - all the stuff is in the System.Data.SqlServerCe namespace):
SqlCeParameter param = new SqlCeParameter();
param.ParameterName = "#SomeParameterName";
param.Direction = ParameterDirection.Input;
param.DbType = DbType.String; // this is the important bit to avoid the exception
param.Value = kvp.Value;
cmd.Parameters.Add(param);
Obviously, you'd want to set the DB type to match the type of your parameter.
I have a problem to catch util.JDBCExceptionReporter during save().
Code:
membership.withTransaction { status ->
try{
def membership = membership.findByUserId(userId)
if(!membership){
membership = new membership(userId: userId, email: userEmail, baseLevel: membership.findByName(membershipName.MEMBER)).save(flush: true)
}
}catch(org.springframework.dao.DataIntegrityViolationException e){
status.setRollbackOnly()
return false
}catch(all){
println "Insert Membership Exception.\n User Id: $userId\n " + e
}
When I create two thread to run this code, it throw a error:
2014-05-06 12:53:07,034 [Actor Thread 5] ERROR util.JDBCExceptionReporter - Duplicate entry 'test#gmail.com' for key 'email'
I don't want to show this error every time when their has two threads doing the same insert, because the first thread will go through and insert successfully, so I don't really care about second one.
My question is how to catch util.JDBCExceptionReporter?
Thanks.
Just guessing:
By default Grails doesn't throw exceptions when saving. To throw integrity exceptions you have to use save(failOnError: true).
So in this case, it's just an internal trace (util.JDBCExceptionReporter is not an exception).
In your case, instead of capturing exceptions I'd use validate before saving so you can get the integrity errors before trying to save.
As lsidroGH said, util.JDBCExceptionReporter is not an exception, it's a log message. It logs both SQLExceptions and SQLWarnings. There is no problem with your code, as one thread will have a save() call that returns true and the other thread's save() will get false.
If you don't want this message to show up in your logs, you will need to increase your log level for org.hibernate.util.JDBCExceptionReporter from ERROR to FATAL but this will potentially exclude valid exceptions you would want logged. Your best bet is to ignore it, as your code works.