ExecuteScalar requires an open and available Connection. The connection's current sta Programming Software Development by abc88 …connection but it gives me the following error: ExecuteScalar requires an open and available Connection. The …Sub Main() try connection.open() cmd.ExecuteScalar() Check1() Check2() Catch() cmd.ExecuteScalar() Finally cmd.ExecuteScalar() <---- gives an error connection.… Re: ExecuteScalar() Only works once...? Programming Web Development by MichaelWClark …WHERE [PRODUCT_NAME] ='CellName'" [/code] The ExecuteScalar then returns the corresponding Product_Model from the DB. With…As New SqlCommand(SelectQuery, SQLConn) Dim RowCnt = SqlCom.ExecuteScalar() SQLConn.Close() SQLConn.Dispose() Dim res As String… Re: ExecuteScalar requires an open and available Connection. The connection's current sta Programming Software Development by GeekByChoiCe … error message pops up: [CODE=vb] Try connection.open() cmd.ExecuteScalar() Check1() Check2() Catch(ex as Exception) MsgBox(ex.ToString) Finally… ExecuteScalar requires an open and available Connection Programming Web Development by cVz …GetConnectionObject() ); try { // Reset the error object ClearError(); return (Int32)comm.ExecuteScalar(); <------- Error here } catch( SqlException ex ) { SetError( ex ); return -1… ExecuteScalar() Only works once...? Programming Web Development by MichaelWClark … in the other dropdown based upon results of executeScalar. If i have the catagory "Cellular"…SqlCom As New SqlCommand(SelectQuery, SQLConn) Dim RowCnt = SqlCom.ExecuteScalar() SQLConn.Close() SQLConn.Dispose() Dim res As String res… Re: ExecuteScalar() Only works once...? Programming Web Development by finito …As New SqlCommand(SelectQuery, SQLConn) Dim RowCnt = SqlCom.ExecuteScalar() SQLConn.Close() SQLConn.Dispose() Dim res As String…; + ddlProductName.SelectedValue + "'", SQLConn).ExecuteScalar().ToString SQLConn.Close() SQLConn.Dispose() [/CODE] Re: ExecuteScalar() Only works once...? Programming Web Development by crishjeny Hi [CODE] public static T ExecuteNullableScalar<T>(this SqlCommand cmd) where T : struct { var result = cmd.ExecuteScalar(); if (result == DBNull.Value) return default(T); return (T)result; }[/CODE] ExecuteRedear vs ExecuteScalar Programming Web Development by rajni11 I am having confusion in ExecuteScalar & ExecuteReader If we use ExecuteReader for select with aggregate … help of only one method ExecuteReader so why is there ExecuteScalar………, is there any other benefit of it? Please give the… Re: ExecuteRedear vs ExecuteScalar Programming Web Development by tgreer … have to do a Read(), then get the value. [B]ExecuteScalar[/B] immediately returns the actual value. So, in terms of… retrieving Scalar data from a database, [B]ExecuteScalar[/B] is more efficient. Re: ExecuteRedear vs ExecuteScalar Programming Web Development by rajni11 … have to do a Read(), then get the value. [B]ExecuteScalar[/B] immediately returns the actual value. So, in terms of… retrieving Scalar data from a database, [B]ExecuteScalar[/B] is more efficient.[/QUOTE] Re: ExecuteRedear vs ExecuteScalar Programming Web Development by chan_lemo follow the link below , it will explain executescalar and executereader. [url]http://vb.net-informations.com/ado.net-dataproviders/ado.net-executescalar-sqlcommand.htm[/url] [url]http://vb.net-informations.com/ado.net-dataproviders/ado.net-executereader-sqlcommand.htm[/url] lemo Re: Error Retrieving Single Data Using ExecuteScalar Method Programming Software Development by bruce2424 follow the url, it explain how to ExecuteScalar [url]http://vb.net-informations.com/ado.net-dataproviders/ado.net-executescalar-sqlcommand.htm[/url] Error Retrieving Single Data Using ExecuteScalar Method Programming Software Development by wonder_gal … = New SqlCommand(sqlText, oConn) strSQLCmd.Connection.Open() [B]sd = strSQLCmd.ExecuteScalar(System.Data.CommandBehavior.CloseConnection)[/B] Return sd End Function [/code… using executeScalar() Programming Software Development by capiono …", SqlDbType.Int, value); con.Open(); returnValue = Convert.ToInt32(cmd.ExecuteScalar()); [/CODE] for instance, if Plan_id is 1 it returns the… Re: ExecuteScalar requires an open and available Connection Programming Web Development by agrothe First off, thats C# and not asp. This needs to be in the ASP.NET forum. Second, if it worked fine and then SQL Connect suddenly stops, check your database not your code. You probably have an offline SQL database. Re: ExecuteScalar() Only works once...? Programming Web Development by dnanetwork use ExecuteReaser() or ExecuteNonQuery() Re: ExecuteScalar() Only works once...? Programming Web Development by finito [QUOTE=dnanetwork]use ExecuteReaser() or ExecuteNonQuery()[/QUOTE] you mean ExecuteReader() ExecuteNonReader will not Return anything. Re: ExecuteScalar() Only works once...? Programming Web Development by MichaelWClark Update: Changed code to: If Not ddlProductName.SelectedValue = "-Select Product-" Then Dim SQLConn As New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString")) SQLConn.Open() Dim SqlCom As New SqlCommand("SELECT [… Re: ExecuteScalar() Only works once...? Programming Web Development by MichaelWClark Okay so....NO Clue what was going on... I scripted out my DB from my SQL Express and put it onto a full version on my test VM and everything is working now....what a waste of time... ASP.net needs to impliment the error: ASP.NET Error Your SQL Server is lame. Thanks for the help all! Re: ExecuteScalar() Only works once...? Programming Web Development by dnanetwork sorry i mean comm.ExecuteReader(); ExecuteScalar requires an open and available Connection. The connection's c Programming Web Development by laura301019 I keep receiving this error and I'm unsure how to fix it. The code I have is protected void AddUserToDatabase(String username, String Password, String Email) { OleDbConnection conn; OleDbCommand cmd; using (conn = new OleDbConnection(ConfigurationManager.ConnectionStrings[&… Re: ExecuteScalar requires an open and available Connection. The connection's c Programming Web Development by pritaeas Sounds like you need to open your connection, before using the command. Re: ExecuteScalar requires an open and available Connection. The connection's c Programming Web Development by aneri28 hii, write conn.Open() before "using (cmd = conn.CreateCommand())" line...bcz u r creating command using conn obj...which is not opened yet... Re: using executeScalar() Programming Software Development by sknake The where condition of your query is wrong. Use: [icode]Where plan_id = [COLOR="Red"][B]@plan_id[/B][/COLOR][/icode] And: [icode]cmd.Parameters.Add("@plan_id", SqlDbType.Int, value);[/icode] Re: Getting the Identity value from an inserted SQL Row Programming Software Development by darkagn ExecuteScalar always returns a single value, so you should use it … need to handle DBNull.Value during your conversion when using ExecuteScalar, but in your specific example this probably won't be… query this would be overkill and I would just use ExecuteScalar instead. Re: Getting the Identity value from an inserted SQL Row Programming Software Development by Teme64 … SqlDbType.DateTime).Value = DateTime.Now; try { Conn.Open(); // ExecuteScalar() returns an object so assign it to a variable which… is of type object scalarObject = EventCommand.ExecuteScalar(); // If the returned object is of integer type … Re: I have a problem with the datagrid Programming Software Development by |-|x ExecuteScalar is for queries that return a single result, eg `SELECT … Questions for Web Gurus! (*??*) Programming Web Development by SheSaidImaPregy … conPubs ) Dim intID1 As Integer = cmdSelect.ExecuteScalar() cmdSelect = New OdbcConnection( "SELECT OOPS… = cmdSelect4.ExecuteScalar() intOops1 = cmdSelect5.ExecuteScalar() intID2 = cmdSelect6.ExecuteScalar() intOops2 = cmdSelect7.ExecuteScalar() intID3 = cmdSelect8.ExecuteScalar() intOops3 cmdSelect9.ExecuteScalar() conPubs.Close… Problem With a Function Programming Web Development by ctyokley …As Object obj = sqlcommand.ExecuteScalar() obj2 = sqlcommand2.ExecuteScalar() obj3 = sqlcommand3.ExecuteScalar() If obj Or obj2 …As Object obj = sqlcommand.ExecuteScalar() obj2 = sqlcommand2.ExecuteScalar() obj3 = sqlcommand3.ExecuteScalar() If obj Or obj2 … My first vb.net function - and I'm stuck Programming Software Development by Levhai … conn2.Open() newPhoneCheck = Convert.ToString(cmdPhoneIDcheck.ExecuteScalar) If newPhoneCheck = "" Then… conn2.Open() newPhoneCheck = Convert.ToString(cmdPhoneIDcheck.ExecuteScalar) Do Until newPhoneCheck <> newPhoneID …