Friday, August 18, 2023

Buggish: Tesla Account Locked, Then Locked Out of Car

I regret purchasing a Tesla.

Account Lock Out, Now I cannot Drive My Car

So, I am trying to lookup my insurance info and try to log in. I sign in, I get to the 2 factor-authentication where it sends a code to my phone. AND IT NEVER COMES! 

Whatever the case... I tried to reset my password to maybe reset the 2FA. WORST MISTAKE! This signs me out of my app and now I cannot use my car at all.



Saturday, August 5, 2023

C# SMO: Unable to get objects by name but able to get by index

Replicating Issue

StoredProcedure sp = db.StoredProcedures["spName"]; // Returns null

Does not return the same as 
StoredProcedure sp = db.StoredProcedures[0]; // Returns object


If I traverse the array (technically a collection), I will find spName. Even if I do:
StoredProcedure sp = db.StoredProcedures[0]; // Returns object
StoredProcedure spByName = db.StoredProcedures[sp.Name]; // returns null


Possible Solution

First I tried. https://www.tek-tips.com/viewthread.cfm?qid=1736324
StoredProcedure storedProcedure =
db.StoredProcedures.Cast<StoredProcedure>().SingleOrDefault(sp => sp.Schema == "YourSchemaName" && sp.Name == "YourSprocName"); 

This worked and this caused me to see that the schema is explicitly entered. After some more research, I could not find how you would provide the schema to the stored procedure name.

Later I tried to look under Database which has a property, DefaultSchema. After setting this, this also returned the correct result.

So the simplest solution:

db.DefaultSchema = "schemaName";
StoredProcedure sp = db.StoredProcedures["spName"]; 

Root Cause Analysis

For my specific case, our DBA changed the default schema of the user.