ado.net

What is the default transaction isolation level in Entity Framework when I issue “SaveChanges()”?

佐手、 提交于 2020-01-09 06:51:10
问题 What is the default transaction isolation level in Entity Framework when I issue “SaveChanges()”? I can not find it anywhere. Shall it be "Serializable"? 回答1: SaveChanges uses implementation of DbTransaction for current store provider. It means that default transaction isolation level is set to default value for the database server. In SQL Server it is READ COMMITTED . If you want to change isolation level you can use TransactionScope . You can also override SaveChanges in your derived

Inserting values into a SQL Server database using ado.net via C#

﹥>﹥吖頭↗ 提交于 2020-01-09 06:50:11
问题 I have created a simple program to insert values into the table [regist] , but I keep getting the error Incorrect syntax near ')' on cmd.ExecuteNonQuery(); : private void button1_Click(object sender, EventArgs e) { SqlConnection cn = new SqlConnection("Data Source=DELL-PC;initial catalog=AdventureWorks2008R2 ; User ID=sa;Password=sqlpass;Integrated Security=SSPI;"); SqlCommand cmd = new SqlCommand("INSERT INTO dbo.regist (" + " FirstName, Lastname, Username, Password, Age, Gender,Contact, " +

Inserting values into a SQL Server database using ado.net via C#

对着背影说爱祢 提交于 2020-01-09 06:49:47
问题 I have created a simple program to insert values into the table [regist] , but I keep getting the error Incorrect syntax near ')' on cmd.ExecuteNonQuery(); : private void button1_Click(object sender, EventArgs e) { SqlConnection cn = new SqlConnection("Data Source=DELL-PC;initial catalog=AdventureWorks2008R2 ; User ID=sa;Password=sqlpass;Integrated Security=SSPI;"); SqlCommand cmd = new SqlCommand("INSERT INTO dbo.regist (" + " FirstName, Lastname, Username, Password, Age, Gender,Contact, " +

Access 2007 - INSERT and instant SELECT doesn't retrieve the inserted data

丶灬走出姿态 提交于 2020-01-09 05:39:16
问题 I'm inserting a few rows in a table via OleDB, and select instantly the inserted row. I can't retrieve the row in this way, i have to wait for approx. 3-5 seconds. And then the inserted row appears in the table. I observed this behavior in the database itself, i inserted the row via OleDB and watched the opened table in Access. The row appeared 3-5 seconds later in the table. Does Access buffer rows? Do i have to send a flush or commit, etc. via OleDB ? Any suggestions would be very helpful.

Access 2007 - INSERT and instant SELECT doesn't retrieve the inserted data

半城伤御伤魂 提交于 2020-01-09 05:39:05
问题 I'm inserting a few rows in a table via OleDB, and select instantly the inserted row. I can't retrieve the row in this way, i have to wait for approx. 3-5 seconds. And then the inserted row appears in the table. I observed this behavior in the database itself, i inserted the row via OleDB and watched the opened table in Access. The row appeared 3-5 seconds later in the table. Does Access buffer rows? Do i have to send a flush or commit, etc. via OleDB ? Any suggestions would be very helpful.

WHERE IN (array of IDs)

混江龙づ霸主 提交于 2020-01-09 02:15:55
问题 I have webservice which is passed an array of ints. I'd like to do the select statement as follows but keep getting errors. Do I need to change the array to a string? [WebMethod] public MiniEvent[] getAdminEvents(int buildingID, DateTime startDate) { command.CommandText = @"SELECT id, startDateTime, endDateTime From tb_bookings WHERE buildingID IN (@buildingIDs) AND startDateTime <= @fromDate"; SqlParameter buildID = new SqlParameter("@buildingIDs", buildingIDs); } 回答1: You can't

DBNull cast to (object) returns different value [closed]

…衆ロ難τιáo~ 提交于 2020-01-07 09:54:33
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I am trying to write DBNull.Value using Parameters.AddWithVallue when an optional parameter (a string ) of a C# method is null . public static void Abc(string distrito, string municipio = null) command.Parameters.AddWithValue("@Municipio", municipio ?? (object)DBNull.Value); command.Parameters.AddWithValue("

DBNull cast to (object) returns different value [closed]

二次信任 提交于 2020-01-07 09:52:06
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I am trying to write DBNull.Value using Parameters.AddWithVallue when an optional parameter (a string ) of a C# method is null . public static void Abc(string distrito, string municipio = null) command.Parameters.AddWithValue("@Municipio", municipio ?? (object)DBNull.Value); command.Parameters.AddWithValue("

How to ensure dates are in correct format for OleDbCommand parameters?

对着背影说爱祢 提交于 2020-01-07 05:41:12
问题 When I execute the code below against an MDB database, the data table is empty, however when I run this in a query tool against the database it returns 2 records. What could be the problem? Is it an issue with the date format of the parameters (ie. 8/5/13 vs 5/8/13)? Using oDB As OleDbConnection = GetDbConnection() Using oCmd As New OleDbCommand("SELECT * " & _ " FROM Table1, Table2" & _ " WHERE (Table1.Date BETWEEN @Date1 AND @Date2) AND (Table1.Id IS NULL) AND (Table2.number = Table1.num)

Exception when calling stored procedure: ORA-01460 - unimplemented or unreasonable conversion requested

ぐ巨炮叔叔 提交于 2020-01-07 02:56:25
问题 I'm trying to call a stored procedure using ADO .NET and I'm getting the following error: ORA-01460 - unimplemented or unreasonable conversion requested The stored procedure I'm trying to call has the following parameters: param1 IN VARCHAR2, param2 IN NUMBER, param3 IN VARCHAR2, param4 OUT NUMBER, param5 OUT NUMBER, param6 OUT NUMBER, param7 OUT VARCHAR2 Below is the C# code I'm using to call the stored procedure: OracleCommand command = connection.CreateCommand(); command.CommandType =