.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Imran Ghani
Post New Web Links

Calculate database query value by using Math expression ?

Posted By:      Posted Date: October 07, 2010    Points: 0   Category :ASP.Net
 

I'm currently develop a monitoring and evaluation database with many indicators

For example: I have two input  indicator :  car , truck

Input_IndicatorID        quantity

Car                               3

Truck                            2

I'd like to create an output indicator have field: formular. The result of vehicle = car + truck = 5

Output_indicatorID      formular

Vehicle                         Car + truck

I don't now how to parse this string, detect parameter: car, truck  to get the answer

I search on Google and find some Math parse like:  muParser, bcnet  but it just for a string

 

Please help me solve this




View Complete Post


More Related Resource Links

Calculate database field by using Math expression ?

  

I'm currently develop a monitoring and evaluation database with many indicators

For example: I have two input  indicator :  car , truck

Input_IndicatorID        quantity

Car                               3

Truck                            2

I'd like to create an output indicator have field: formular. The result of vehicle = car + truck = 5

Output_indicatorID      formular

Vehicle                         Car + truck

I don't now how to parse this string, detect parameter: car, truck  to get the answer

I search on Google and find some Math parse like:  muParser, bcnet  but it just for a string

 

Please help me solve this


Syntax error (missing operator) in query expression

  
Good Day Gurus!

I have a Excel user application which has a user form (named 'Registo') that displays criteria and an image that has been entered in it's corresponding spreadsheet. This works the way it should.  There's also the ability to search the spreadsheet via a form (by clicking 'Pesquisar' button) this opens a search form. However, I having a bit of a problem with it. When I try to search for something it basically doesn't do anything at all. It just sits there. So I tried to debug it and I think I'm having a problem with either the JET db engine or somethign with teh query or maybe I don't have the correct reference.

I 'borrowed' this Excel application from another forum because it's exactly what I'm looking for! However, I suck at vb.

So I was hoping somebody could take a look at the code and see if I'm missing something?  I'm kinda' desparate to get this working because I'm been trying to figure it out for days and I'm running out of time.  Cry
 
Option Explicit

'constantes para auxiliar na verificação do código
Private Const Ascendente As Byte = 0

How to perform math on a column of data in SQL database and display it in my VB app

  
Sorry if this is the wrong forum, cos it's SQL and VB2010 So I have my sqlserver database 3.5 compact editon called "Dive Club Records" and in it are stored columns of dive trip information and I want tthe user to be able run a query from my VB2010 application to sum a divers total dive hours and display it on the form, eg: MemberID, FirstName, LastName, DiveTime by the way divetime is a real number recorded as 15.5, 20.5, 5.0 etc What is the easiest way to do this? Would prefere to do it from within VB2010 code if possible or make a query from the datagrid on my form using query designer. thanks for any suggestions from you all, hope you can keep them simple for me :)   regards   paul   paul

Write select query with a paremetrized where clause, and populate database with the retrieved column

  
I want to be able to retrieve column values using the dropdownlist values as parameters then populate the tbPO table with the retreived values. Where and how do I do it. ImportsSystem.Data.OleDb ImportsSystem ImportsSystem.IO Imports ?directcostDataSetTableAdapters PartialClass po_header  Inherits System.Web.UI.Page  Dim cn As OleDbConnection  Dim cmd As OleDbCommand  Dim dr As OleDbDataReader  Dim icount As Integer  Dim str As String  Dim vendor_id As Object   ?  Public Sub btn_click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.ClickTry   context.Items.Add(     cmd.CommandType = System.Data.   cmd.CommandText = Dim context As HttpContext = HttpContext.Current"Company_Name", DropDownList3.Text)Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Users\Owner\Documents\Visual Studio 2010\WebSites\WebSiteJun25\App_Data\directcost.mdb;")Dim cmd As New OleDbCommand()CommandType.Text"insert into tbPO(ponumber, suppliername, ShipTo, basictype, DateNeeded, Purpose,ShippingInstr, ProjId) values(?,?,?,?,?,?,?,?)" cmd.Parameters.AddWithValue( cmd.Parameters.AddWithValue( cmd.Parameters.AddWithValue( cmd.Parameters.AddWithValue( cmd.Parameters.AddWithValue( cmd.Parameters.AddWithValue( cmd.Parameters.AddWithValue( cmd.Parameters.Add

Expression for Query.CommandText

  
Hi, I have an extensive query.commandtext in a report that access a SQL Server 2000 server and I'm getting this error message: "FORMULA ERROR: CANNOT CONVERT SET TO TUPLE - IN THE {...} FUNCTION". Any help will be very appreciated. This is the command: = " WITH MEMBER [Data].[Fiscal Year].[All Data].[Atual] As ' [Data].[Fiscal Year].[Ms].[ " & Parameters!MES.Label & "] ' SET [Medida] AS ' { [Measures].[Previso], [Measures].[Total Carteira], [Measures].[Faturado], [Measures].[vlICMI], [Measures].[vlFaturado], [Measures].[NIV Target], [Measures].[NIV Carteira], [Measures].[NIV Faturado], [Measures].[PPR Pedido %], [Measures].[PPR Faturado %], [Measures].[PPR Pedido], [Measures].[PPR Faturado], [Measures].[TPR Pedido], [Measures].[TPR Faturado],   [Measures].[Agreement on Invoice], [Measures].[Agreement on Invoice NF], [Measures].[NSV Estimado] } ' MEMBER [Produtos].[Linha].[Linha].[Caf].[Pilo Vero] As ' Aggregate({ [Produtos].[Linha].[Produto].[001250 - CAFE PILAO SABOR DE VERAO ALMOFA 10X500G], [Produtos].[Linha].[Produto].[001251 - CAFE PILAO SABOR DE VERAO ALMOFA 20X250G], [Produtos].[Linha].[Produto].[001285 - CAFE PILAO SABOR DE VERAO VACUO 20X500G], [Produtos].[Linha].[Produto].[001286 - CAFE PILAO SABOR DE VERAO VACUO 20X250G], [Produtos].[Linha].[Produto].[001290 - CAFE PILAO SABOR DE VERAO ALMOF 90X40 G] }) ' M

using a database field as a hyperlink query?

  
I have three tables in my sql database contactssurvey answersrespondent_initialContacts holds all customer data with custid. survey answers has assigned everyone how took the survey a number in a field called respondent_no.respondent_initial holds input from a webform where I populated it with the custid from contacts and respondent_no from survey answers before the webform input is inserted. I want to send an email to them that had there respondent_no in a hyperlink to the webform so that when they entered their data into the webform it would use the repondent_no to determine where to insert the form data.Example joe clicks http://www.myplace.com/order.aspx?23             Mike clicks http://www.myplace.com/order.aspx?125it would look up respondent_no (23) from the respondent_initial table and insert the data in that row in the database for joe's webform entry and it would look up respondent_no (125) from the respondent_initial table and insert the data in that row in the database for mike's webform entry.my code behind looks like this// Create command                comm = new SqlCommand("INSERT INTO respondent_inital (Practice_Name, Address1, Address2, City, State, Zipcode, Phone, Email, Contact, Dealer, item_9223, item_9129, item

How to calculate a SQL Server performance of a query based upon table schema, table size, and availa

  
Hi What is the best way to calculate (without actual access to a SQL Server) the processing speed of a query (self-inner-join) based upon table schema, table size, and hardware (CPU, RAM, Drives)? ThanksThanks Jeff in Seattle

How to extend this query to write the results back to a database?

  
FOr this query I have four tables I would like to access. SELECT StockA, SUM(Score) AS Total FROM dbo.ScoresNew_LongPrice WHERE [When] >= @StartTime AND [When] < @EndTime GROUP BY StockA ORDER BY SUM(Score) DESC _LongPrice, _ShortPrice, _LongVolume, _ShortVolume I would like to improve the above query to return not just the results from LongPrice, but four columns, of sum(score), from each table, if possible. And, if that is possible, I would also like to have the query then update another table with its results.  Not a new table, but just updated to an existing table. Anyway, I can do some stuff in T-SQL but this seems over my head.  Any help would be appreciated. (The four tables all have identical structures)

how to count transactions done on your database by T-SQL query?

  

Dear All,

I have multiple database and I want to know how many transaction that are happening per database using T-SQL, can anyone help me?

 

Regards,

 

Karim


Karim Alaa

query all tables in the database with slightly different query

  
USE DBNAME
GO

Declare @Table_Name varchar(50)

DECLARE table_cursor CURSOR FOR
SELECT Name
FROM sys.Tables

OPEN table_cursor

FETCH NEXT FROM table_cursor
INTO @Table_Name


While @@FETCH_STATUS = 0
BEGIN
  SELECT * FROM @Table_Name

 FETCH NEXT FROM table_cursor
  INTO @Table_Name

END
CLOSE table_cursor
DEALLOCATE table_cursor

The above code gives error, maybe I am mistaken about the way cursors work.

 

But how can I acheive the same pirpose

 

I want to query all tables in the database with the same query in which the where condition will slightly vary.

The above gives this error

 

Msg 137, Level 15, State 2, Line 8
Must declare the scalar variable "@Table_Name".
Msg 1087, Level 15, State 2, Line 13
Must declare the table variable "@Table_Name".
Msg 137, Level 15, State 2, Line 16
Must declare the scalar variable "@Table_Name".

 

 


Please solve the Database problem (calculate the in and out timing) screech Card in and out timings.

  
Hey, Dear Friends.. Goody, I need a help from you people. Those who know the more database(prosegers) please salve this problem. The following is my database table. In that, want to calculate each employee out time and in time. I mean how much hr they are spending out side of the company and how much hours they are spending inside of the company in that day. Thanks in Advance. SuraReddy. Emani empcode CardNo emp_code_name time IOGateNo Door in_out date 0022 0022 XYZ 09:09:50 02-1 MAIN DOOR(I/O) Entry 2010-09-08 0022 0022 XYZ 09:50:40 02-5 MAIN DOOR(I/O) Exit 2010-09-08 0022 0022 XYZ 10:02:31 02-1 MAIN DOOR(I/O) Entry 2010-09-08 0022 0022 XYZ 11:31:56 02-5 MAIN DOOR(I/O) Exit 2010-09-08 0022 0022 XYZ 11:45:25 02-1 MAIN DOOR(I/O) Entry 2010-09-08 0022 0022 XYZ 13:48:51 02-5 MAIN DOOR(I/O) Exit 2010-09-08 0022 0022 XYZ 14:30:25 02-1 MAIN DOOR(I/O) Entry 2010-09-08 0022 0022 XYZ 16:16:15 02-5 MAIN DOOR(I/O) Exit 2010-09-08 0022 0022 XYZ 16:33:27 02-1 MAIN DOOR(I/O) Entry 2010-09-08 0022 0022 XYZ 18:40:58 02-5 MAIN DOOR(I/O) Exit 2010-09-08 0022 0022 XYZ 09:04:41 02-1 MAIN DOOR(I/O) Entry 2010-09-09 0022 0022 XYZ 10:21:22 02-5 MAIN DOOR(I/O) Exit 2010-09-09 0022 0022 XYZ 10:30:06 02-1 MAIN DOOR(I/O) Entry 2010-09-09 0022 0022 XYZ 12:44:43 02-5 MAIN DOOR(I/O) Exit 2010-09-09 0022 0022 XYZ 09:08:24 02-1 MAIN DOOR(I/O) Entry 2010-09-14 0022 0022 XYZ 09:43:29 02-5

database query problems

  

Hello All, I have a result table in MS SQL Database server (2005).

Subject   Exam                 SubExam   Year     Marks

Math       First Terminal    CT              2010    18
Math       First Terminal    Hall Exam   2010    67.2

Science   First Terminal    CT              2010    20
Science   First Terminal    Hall Exam   2010    78


Now how can I get the result followningly


                                First Terminal

                        CT       Hall Exam      Total

Math      

Imagemap connection to database query

  

Hi,

I have an imagemap that works: 


Protected Sub ImageMap1_Click(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ImageMapEventArgs) Handles ImageMap1.Click
Select Case (e.PostBackValue)
Case ("Dublin")
Label1.Text =

"You selected " & e.PostBackValue
Case ("Cork")
Label1.Text =

"You selected " & e.PostBackValue
Case ("Southern")
Label1.Text =

"You selected " & e.PostBackValue
Case Else
Label1.Text =

"You did not click a valid hot spot region."
End Select


All the postback values are correct. Instead of sending the postback value to a label I want to use this in a select statement with a database. How do I achieve this? The output should be sent to a gridview.


Many thanks.



SQL Server Agent Job And Database Mail - Error formatting query, probably invalid paramters

  

We have a stored procedure that we are trying to call with a SQL Server Agent Job. The stored procedure calls Database Mail. This is SQL 2008. The execute task is simply:

 

USE [Production]
GO

EXEC [dbo].[JOB_EMAIL_SCHEDULED_REPORTS]

GO

 

When the job runs, it is erroring out immediately, with the error:

Execute as user: NT AUTHORITY\NETWORK SERVICE. Error formatting query, probably invalid paramters [SQLSTATE 42000] (Error 22050). The step failed.

When we go into SQL Server Manager and just execute the SQL query, it works though. Something within the SQL Server Agent job,  and Database Mail is causing problems. Any ideas? Thanks.

 

 


Showing Null value in a string expression to show fullName in T-SQL query

  

Hi,

I have a SQL query which calculates the full name from firstname, middlename and lastname. When any of the column contains a null value the calculated value shows null.

select

FirstName + ' ' + MiddleName + ' '+ LastName as FullName

from <table name>

FirstName : Ruben

MiddleNAme : Null

LastName : Torres

FullName : Null

Why it does not leave the null column and have the string concatanated as :

Ruben Torres

 

Thanks,

Grahi.


How can I query blob columns from Paradox database via ODBC?

  

Hi,

I want to read blob columns from Paradox database using c#. Here is my code:

  DataSet dsUsers = new DataSet();

  string strQuery = "SELECT blobColumn FROM users";

  dsUsers = GetNames(strQuery, "Driver={Microsoft Paradox Driver (*.db )}; Default Dir=<directory>;DBQ=<directory>");


 
 private DataSet GetNames(String strQuery, String strConnect)

 {

  DataSet dsNames = new DataSet();

  try

  {

  OdbcConnection conOdbc = new OdbcConnection(strConnect);

  OdbcCommand cmdOdbc = new OdbcCommand(strQuery, conOdbc);

  OdbcDataAdapter odaOdbc = new OdbcDataAdapter(cmdOdbc);

  odaOdbc.Fill(dsNames);

  conOdbc.Open();

  conOdbc.Close();

  }

  catch (OdbcException eExc)

  {

  }

  catch (Exception eExc)

  {

  }

  return dsNames;

 }


Note that the Paradox driver version is 4.0.

The code failed to query the blob column.  The error is:

Error code: -2146232009
 Error msg: ERROR [07002] [Microsoft][ODBC Paradox Driver] Too few parameters. Expected 1.
 Source: odbcjt32.dll

Please note that I can query non-blob columns of the table with the same code.

How to query a datetime field in access database using ASP.NET

  

Hello

I am using an Access database with one of the Table columns defined as Date/Time field.

 

I am trying to use ASP.NET 4.0 Web forms application to query and retrieve the row based on the DateTime field.

Here is my code snippet:

      string connectionString = WebConfigurationManager.ConnectionStrings["AccessDB"].ConnectionString;

      OleDbConnection oleDBConn = new OleDbConnection(connectionString);

      DateTime dt = new DateTime(dtBatchCreation.Year, dtBatchCreation.Month, dtBatchCreation.Day, dtBatchCreation.Hour, dtBatchCreation.Minute, dtBatchCreation.Second);

      //string sql = "SELECT [BatchID] FROM [Batch] WHERE [BatchCreationDate] = " + String.Format("{0:#yyyy-MM-dd hh:mm:ss tt#}", dt);
     
      string sql = "SELECT [BatchID] FROM [Batch] WHERE [BatchCreationDate] = @BatchDate";

      string s = @String.Format("{0:yyyy-MM-dd HH:mm:ss}", dt);

      OleDbCommand cmd = new OleDbCommand(sql, oleDBConn);

      //cmd.Parameters.AddWithValue("@BatchDate", s);

   

Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend