datareader

“Use of unassigned variable” error

你。 提交于 2021-02-17 05:46:29
问题 I am developing this website in ASP.NET and using C#. I am Getting the error that :Use of unassigned variable usn. The database is also not empty. My code is: protected void Button1_Click(object sender, EventArgs e) { SqlConnection cn = new SqlConnection(); SqlCommand cm = new SqlCommand(); SqlDataReader dr; cn.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Vijaylaxmi\Desktop\TrainReserveold\App_Data\Database.mdf;Integrated Security=True;User Instance=True"; cn.Open()

.NextResult() method does gives an error that states that no data is present

こ雲淡風輕ζ 提交于 2021-02-10 19:50:53
问题 Can you check my coding and let me know what I'm doing wrong? I'm trying to use the .NextResult() method of a DataReader but I get an error that no data is present. The 1st query returns a value but the 2nd query is the problem. Dim strSqlStatement As String = "Select Count(*) As TotalRows " & _ "From Parents " & _ "Where (FatherName = @SearchValue " & _ " Or MotherName = @SearchValue);" strSqlStatement = strSqlStatement & "Select FatherName, MotherName " & _ "From Parents " & _ "Where

.NextResult() method does gives an error that states that no data is present

醉酒当歌 提交于 2021-02-10 19:50:41
问题 Can you check my coding and let me know what I'm doing wrong? I'm trying to use the .NextResult() method of a DataReader but I get an error that no data is present. The 1st query returns a value but the 2nd query is the problem. Dim strSqlStatement As String = "Select Count(*) As TotalRows " & _ "From Parents " & _ "Where (FatherName = @SearchValue " & _ " Or MotherName = @SearchValue);" strSqlStatement = strSqlStatement & "Select FatherName, MotherName " & _ "From Parents " & _ "Where

SQL DataReader network usage limit

半世苍凉 提交于 2021-02-08 19:45:46
问题 I have such an idea (don't know bad or good). I have utility, which connects by reglament to SQL server and fetches some data to application. Data is simple (2 varchar text attributes), but count of data is ~ 3 millions rows. So, my application uses network very intensively. Can I programmatically decrease (limit, throttling, etc...) the network bandwidth usage by SQL DataReader ? Let it work more slowly, but not stress nither server nor client. Is this idea good? If not, what I have to do so

SQL DataReader network usage limit

一世执手 提交于 2021-02-08 19:43:49
问题 I have such an idea (don't know bad or good). I have utility, which connects by reglament to SQL server and fetches some data to application. Data is simple (2 varchar text attributes), but count of data is ~ 3 millions rows. So, my application uses network very intensively. Can I programmatically decrease (limit, throttling, etc...) the network bandwidth usage by SQL DataReader ? Let it work more slowly, but not stress nither server nor client. Is this idea good? If not, what I have to do so

SQL DataReader network usage limit

烂漫一生 提交于 2021-02-08 19:42:39
问题 I have such an idea (don't know bad or good). I have utility, which connects by reglament to SQL server and fetches some data to application. Data is simple (2 varchar text attributes), but count of data is ~ 3 millions rows. So, my application uses network very intensively. Can I programmatically decrease (limit, throttling, etc...) the network bandwidth usage by SQL DataReader ? Let it work more slowly, but not stress nither server nor client. Is this idea good? If not, what I have to do so

DataReader.GetString() via columnname

喜夏-厌秋 提交于 2020-03-09 04:58:25
问题 Dictionary Fields = new Dictionary(); for (int i = 0; i < reader.FieldCount; i++) { Fields.Add(reader.GetName(i), i); } this._MyField1 = reader.GetString(Fields["field1"]); this._Myfield2 = reader.GetInt16(Fields["field2"]); doing this makes me want to cry but i can't seem to figure out how to use the type specfic retrieval methods by column name other than this way. please tell me there is a better way. this is specificly for DB2 but i would like the solution to work for MS Sql also if

Using datareaders with sqltransactions

你。 提交于 2020-02-02 12:59:47
问题 I am using SqlTransaction s in my code for roll back purpose. Within the transaction I got multiple statements to be executed with may include selects inserts and updates. All these statements are within the scope of the sqltransaction . Everything works fine just for one problem. I am using datareader s for select statements . And these readers are closed once they are used. This forces the connection to be lost and every thing fails. Does any one have a solution on whether I can use