[Solved] Sql: Incorrect syntax near ‘(‘ [closed]

Missing space and closing ) protected void Page_Load(object sender, EventArgs e) { string dsn = “foo”; string sql = @”SELECT * FROM ( SELECT F.Project AS ‘Project Number’, F.Account AS ‘Account’, F.Pd AS Period, F.Incurred AS Totals, C.Project AS ‘Project Name’ FROM Ultron.Final F INNER JOIN Ultron.Custom C ON F.Project = C.Project WHERE F.Project LIKE … Read more

[Solved] Search SQL by date ASP.NET

You should parameterized your query. DateTime doesn’t have any format associated with it, Format is only useful for displaying purpose. OleDbCommand cmd = new OleDbCommand(“Select * From TEST WHERE MatchDate >= @matchDate”, conn); cmd.Parameters.AddWithValue(“@matchDate”, DateTime.Today); // Just date part comparision // Or use DateTime.Now depending on your requirement) OleDbDataAdapter da = new OleDbDataAdapter(cmd); da.Fill(ds); This … Read more

[Solved] Need to create column and add values (Date) to a that column SQL

If you need to update an existing table, check out this guide: http://www.w3schools.com/sql/sql_update.asp Edit: To update a table in SQL you would use a query that looks like this: UPDATE table_name SET column1=value1,column2=value2,… WHERE some_column=some_value; –This line is not necessary. –You can add this if you wish to only update certain rows –e.g WHERE Date … Read more

[Solved] Query database then email posts from where user is subbed to

I figured it out. Just use ob_start(), and loop through each user. Select the posts they’re subscribed to. Then inside the loop email it to each user. I used this query SELECT articles.* FROM articles INNER JOIN subscriptions ON articles.from_id = subscriptions.sub_to INNER JOIN users ON subscriptions.user_id = users.id WHERE users.email = :email 5 solved … Read more

[Solved] ASP.NET Login, invalid password

EDIT Now that I look closer there are many things wrong with this code. Standard practice is to check for the username/password combination in one shot: mysql = “SELECT 1 FROM [User] WHERE UserName=? AND Password=?”; OleDbCommand CheckUser = new OleDbCommand(mysql, con); // Add OleDbParameters here with the correct type/length CheckUser.Parameters.Add(“@userName”, OleDbType.Char, 20).Value = tbUser.Text … Read more

[Solved] How to create a query for this scenario?

I think you can try this to obtain a list for all the users (left join with table user in this case is not enough – see my sample data below): SELECT C.USERNAME, A.CALENDARDATE , CASE WHEN B.USERNAME IS NULL THEN ‘Absent’ ELSE ‘Present’ END AS STATUS , CAST(B.WDT AS DATE) AS WDT, CAST(B.WDT AS … Read more