Yes, you are certainly right he might have declared at the beginning of the code snippet which he hasn’t pasted. All I tried just to show him the path I expect he should be able to carry on with the solution and implement the other checking’s which are absolutely required like checking for Null.
On Wed, Jul 8, 2009 at 11:47 PM, Cerebrus <[email protected]> wrote: > > I think you are mistaken in your assumption(s). I believe that the OP > has already declared the "SqlRS" variable as an SqlDataReader (but did > not insert that in the presented code). It wouldn't even compile > otherwise. > > The solution you present will work, however, it will throw an > exception in case any of the column values contains Null. I do not > normally recommend calling ToString() on ANY unchecked variable. > > On Jul 8, 3:33 pm, Jay Dan <[email protected]> wrote: > > I think you are new in .net. You might me migrating from ASP 3.0. > > > > First of all there is no recordset concept in .net. > > > > SqlRs = sqlcmd.ExecuteReader() > > > > ExecuteReader will return a reader so declare a SqlDataReader > > > > Say > > > > SqlDataReader reader; > > > > Now > > > > Reader= sqlcmd.ExecuteReader(); > > > > Check if the reader contains data > > > > If(reader.Read()) > > > > Now read the number of columns returned in your case it should be 3. > > > > reader["EST_NAME"].ToString(); > > > > reader["OFF_NAME"].ToString(); > > > > reader["node"].ToString(); > > > > multiple rows might be returned depending upon the query if the number of > > results returned is one do this to print on the label > > > > label1= reader["EST_NAME"].ToString()+”, ”+reader["OFF_NAME > "].ToString()+”, > > ”+reader["node "].ToString() > > > > On Wed, Jul 8, 2009 at 11:30 AM, gagandeep sharma > > <[email protected]>wrote: > > > > > > > > > > > > > strsql1 = > > > " select EST_NAME + ',' + OFF_NAME + ',' + DIS_NAME as node from > > > grievancedetailscomplete where (EST_CODE='" & PEN_EST_CODE & "' AND > > > GRV_CODE=" & PEN_GRV_CODE & ")" > > > > > dbcon = > > > New SqlConnection(ConfigurationManager.ConnectionStrings( > > > "PGConnectionString").ConnectionString) > > > > > sqlcmd = > > > New SqlCommand(strsql1, dbcon) > > > > > sqlcmd.CommandText = strsql1 > > > > > sqlcmd.CommandType = CommandType.Text > > > > > dbcon.Open() > > > > > SqlRs = sqlcmd.ExecuteReader() > > > > > Label1.Text = strsql1 > > > > > sqlcmd.Dispose() > > > > > dbcon.Close() > > > > > -------------------- > > > > > in the above code i want to give the result of select statement to a > > > lable1, but i failed > > > > > if anyone know that, then pls help me > > > > > -- > > > GO and LEAD from Whereever You are. > > > Think Big and Think Fast. > > > > -- > > Regards > > Jay Dan- Hide quoted text - > > > > - Show quoted text - -- Regards Jay Dan
