I have this code, that i use to get data from a database.
Code:
Using connection As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("MyConnStr").ConnectionString)
Using command As OleDbCommand = New OleDbCommand("select * from TableTest", connection)
command.Connection.Open()
Using reader As OleDbDataReader = command.ExecuteReader(CommandBehavior.CloseConnection)
While reader.Read()
[Code]..
how can i add 2 sql statsment to that code !?
First of all i need to know is an record is in the db. and if its in the db i need to know if status is activ or notactiv
"select * from TableTest where email = 'test@tester.dk'" if this is OK, then i need to know if Status is "activ" or "notactiv"
how do i do that and how do i response.write one thing if email is not in the db, and another thing if the email is in the db and the status is activ and a 3. response.write if its in the db and the status is notactiv.
BTW do i need to add a reader.close() between the end.while and end.using !?
How would i make a select statement select the row with the nearest values? e.g.: I have 3 labels, labels1 2 and 3, with values of 1.2, 2 and 5.8 In my table i have 4 columns, first is the data im after, and the next 3 relate to the three labels. I want to select one row, where the values of labels match it the closest.......
anyone know that can we used select statement to called queries table in database or not?usually people used select statement to called common table in database.
I am getting the following error The DELETE statement conflicted with the REFERENCE constraint "FK_Person_Country_CountryID_CountryID". The statement has been terminated. I do not want the user to delete the country if there are any FK contrains. Or a better way will be to ask the user if they want to delete the records referencing this "Country".
My students are working on an ASP.net VB application for a Web Programming competition and we are having problems with a page where we want an URL string to return all values from our database. Here is the page: [URL] If you use the jobs by category menu on the left side, if you select a job category (ie retail) it will pull up all the jobs from that category. By using a query in the URL like this: [URL] What we need is an option that would pull up all of the records regardless of category. So we made a menu option that passes the value "all". Like this: [URL] We use this information for the dataset we created (we're using Dreamweaver, ASP.net VB and and Access Dbase). We made a dataset SQL as follows:
SELECT * FROM jobs, businesses WHERE jobs.contactlogin=businesses.contactlogin and jobcategory = ? ORDER BY jobs.dateposted DESC
This works fine if a value is passed. For example if "retail" is picked from the menu it passes the value just fine and returns all jobs that have "retail" as the job category in the database. My problem is, how do I modify the above Select statement to show all jobs in the database if the value "all" is passed for the jobcategory. My first thought was to create an If statement that says something to the effect of:
If jobcategory = all THEN SELECT * FROM jobs, businesses WHERE jobs.contactlogin=businesses.contactlogin ORDER BY jobs.dateposted DESC ELSE SELECT * FROM jobs, businesses WHERE jobs.contactlogin=businesses.contactlogin and jobcategory = ? ORDER BY jobs.dateposted DESC END IF
But I haven't been able to figure out the correct syntax. I also tried making this work by using a query in MS Access:
SELECT * FROM jobs, businesses WHERE jobs.contactlogin=businesses.contactlogin AND (jobcategory = @jobcategory or @jobcategory = 'all') ORDER BY jobs.dateposted DESC;
(which does work within MS Access) and calling the query in the Dreamweaver dataset but apparently MS Access can't do that.This seems like it should be easy but so far this problem is kicking my butt.
I have a website in asp.net4.0 with database in sqlexpress 2008 and host it On server with DotNetPanel.but I get error 500 when i try to view it.the problem is my web.config surely.but i can't find the mistake,thus I set custom error to off.but yet iI couldn't found the problem.the bold texts represents the codes that i have added to text.my site don't haveany security or don't use the roles and other.
<?xml version="1.0"?> <!-- For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=169433 --> <configuration> <connectionStrings> <add name="connection" connectionString="Server=serverAddress;Database=DBname;Uid=username;Password=password;" /> <add name="ConnectionString" connectionString="Server=serverAddress;Database=DBname;Uid=username;Password=password;" /> </connectionStrings> <system.web> [code]...
I'm trying to make a login Form for my Databse so I can restrict access to the Database. However I constantly get an Invalid Username error when I try to log in. I have copied the Login template from VS 2010 and editted so it should use my own models.
I know how to create an AccessDataSource on my aspx page and how to use the datasource to populate gridviews, etc. But I want to know how I can programmatically populate a dataset by querying an Access database. How do I make queries to an Access database programmatically?
I am working on a project. Completed conceptual model of Database is done in EntityFrameWork. Database is not created yet. Should I make a dummy Records with dummy repository and go on development without creating database and once all done than just created the DB and turn dummy repositories to live? . Is it right decision or should I start making database to work with it from the start?
I want to make my queries better but have been un-able to find a resource out there which lays out when a query is shipped of to the db.
DBContext db = new DBContext(); Order _order = (from o in db where o.OrderID == "qwerty-asdf-xcvb" select o).FirstOrDefault(); String _custName = _order.Customer.Name +" "+_order.Customer.Surname;
Does the assignment of _custName need to make any request to the database?
I need to make a backup file(.bak) of a database(.mdf)
I learned I need to use MS SQL Server management studio Express to do so, but I can't figure it out how.
I don't know how to connect to the database using this program. In the "Connect to Server" dialogue window, I am supposed to choose a server name from the dropdown list, but nothing comes up. What am i doing wrong?
I need to make a back up file(.bak) from my database (.mdf)
I learned that i need to use Ms SQL Server management studio express. I can't figure out how to connect to the database. looks like I need to select a server type, but nothing comes up for me to select. The databse was made using visual developer 2008 ms sql server, so i thought something like "SQl Server 2005 or 2008" comes up, but it didn't.
I am trying to input some data into the database and it just won't make INSERT. Before, I am checking for duplicate entry and then I am trying to insert the data. Here is the code:
In the end I have the warning that con.Close() - unreacheable code detected.
have a very important issue,i have three Stored Procedures Sp1,Sp2 and Sp3 .the first one (Sp1) will execute the second one (Sp2) and save returned data into @tempTB1 and the Second one will execute the third one (Sp3) and save data into @tempTB2.if I execute the Sp2 it will works and it will returned me all my data from the Sp3 ,but the problem is in the Sp1, when i execute it it will display this Error:INSERT EXEC statement cannot be nested I tried to change the place of execute Sp2 and it display me another error:Cannot use the ROLLBACK statement within an INSERT-EXEC statement.