I am using Visual Basic 2008 and Sql Server 2000.
On all Forms I m saving a followup date user select a date and it saved in a relevant table, now at stored follow up date I need to pop up a bar or a notification inside application to tell user that this is you follow up date for this specific record.
Which are the ways I can do it.
any idea will be appreciated
Thanks
I don't understand your question completely. I don't know its for Windows form or Web form (Asp.net) Still I am trying to answer it
You can use SELECT IDENT_CURRENT(‘MyTable’) after your insert command in your stored procedure to get the last inserted id or to verify that it inserted data into table or not.
public int InsertDate(string pid, string followUpDt)
{
Try
{
SqlParameter[] param = new SqlParameter[2];
param[0] = new SqlParameter("#pid", pid);
param[1] = new SqlParameter("#isScraped", isScraped);
int identityId = (Int32)SqlHelper.ExecuteScalar(CommonCS.ConnectionString, CommandType.StoredProcedure, "Sproc_FollowUpDate_Insert", param);
if(identityId != null)
{
// it means Values has been inserted to the table
// Call a Java Script function to Show popup & message
ScriptManager.RegisterStartupScript(Page,GetType(),"showConfirmPopup","<script>disp_confirm()</script>",false)
}
else
{
//Operation not successful
}
}
}
}
Catch(exception ex)
{
//Log Exception to DB OR Send Error Email
}
///In Aspx
<script type="text/javascript">
function showConfirmPopup() {
var msg = "Successful "
//Show Popup code here
</script>
============================UPDATED ANS====================================
Alright You need to create a SQL Job make it occurring daily at specific time. SQL Job will call a Web service url(Invoke) through Stored Procedure
Check this
Now you can check database dates against current date in that web service.
Related
I need to know if a locale appcelerator/titanium database exist in an app to be able to migrate data from that DB to ArrowDB.
Is there any way of finding out if a DB exist by its name?
I tried following this answer but didn't succeed.
https://archive.appcelerator.com/question/143890/check-if-local-database-already-exists
// SDK 5.5.0 GA. iOS & Android
Ended up doing this in my index.js as i find it to be a reliable option.
var db = Ti.Database.open("workoutsDB");
try {
var rows = db.execute('SELECT * FROM workouts ORDER BY date DESC');
rows.close();
//If this code block runs the local database exist.
Alloy.Globals.localDatabaseDoesExist = true;
}
catch (error) {
//Gives an sql error when the table does not exist
Alloy.Globals.localDatabaseDoesExist = false;
}
db.close();
Now I am creating a simple banking project for learning purpose where I need to do a lot of search, update and insert operations for a simple action. For example, if I want to create a transaction from a sample user id, in the "Create Trasaction" Screen, after inputting the details and pressing "submit" button, my application will do the following actions.
1) Insert a row in login session table with values: IP address, user id and timing.
2) To check if the particular user id has access to create a transaction option from user access table.
3) To check if the accounts being debited/credited belong to the same branch code as the home branch code of the creating user.
3) To check if the input inventory (if any) i.e. DD, Cheque is valid or not from inventory table.
4) To check if the account being debited/credited has freeze or not.
5) To check if the account being debited has enough available balance or not.
6) Check the account status Active/Inactive or Dormant.
7) Check and create service tax if applicable i.e. another search from S.Tax table and insert into accounts transaction table
and finally,
8) Insert a row into the accounts transaction table if the criteria pass.
Now I do not feel comfortable to write so many preparedstatement code in my Servlet for only creating a transactions. There will be other operations in my application too. So I was wondering if there is a way we can simply write these SQL statements and pass the SQL file to the Servlet anyway. Or maybe we can write a function in PL/SQL and pass the function to the servelt. Are these ways possible?
Please note, I am using J2EE and Oracle database.
I did this once with a project I was doing some years back and I actually achieved something close to what you are looking for I created a properties file in this format:
trans.getTransactons=select * from whateverTable where onesqlquery
trans.getTranId=select tran_id from whatevertable where anothersqlquery
So that when you write your classes you just load the Properties from the file and the query is populated from the property: for example: This Loads the Property fle
public class QueriesLoader {
Properties prop;
public QueriesLoader() {
}
public Properties getProp() {
prop = new Properties();
ClassLoader classLoader = getClass().getClassLoader();
try {
InputStream url = classLoader.getResourceAsStream("path/to/your/propertiesFile/databasequeries.properties");
prop.load(url);
} catch (IOException asd) {
System.out.println(asd.getMessage());
}
return prop;
}
}
And then in you Database Access Objects
public ArrayList getAllTransactions() {
ArrayList arr = new ArrayList();
try {
String sql = que.getProp().getProperty("trans.getTransactons");
PreparedStatement ps = DBConnection.getDbConnection().prepareStatement(sql);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
arr.add(rs.getString(1));
}
DBConnection.closeConn(DBConnection.getDbConnection());
} catch (IOException asd) {
log.debug(Level.FATAL, asd);
} catch (SQLException asd) {
log.debug(Level.FATAL, asd);
}
return arr;
}
And I ended up not writing a single Query Inside my classes. I hope this Helps you.
I'm "trying" to create a Safari Extension that adds links to a local sqlite database.
In the global.html file, I can create the database, but I can't create a table unless I refer to a non-existant variable, which makes the rest of the script fail.
// Global Variable to hold my database
var my_DB;
// Make A Database
init_DB();
// Make A Table
createTable(my_DB);
// Rest of the code
alert("Database and Table have been created!");
// Initialise the Database
function init_DB() {
try {
// Check for Database Support
if (!window.openDatabase) {
alert("Database functionality is NOT Supported!");
} else {
// Setup the database
var shortName = "imp_DB";
var version = '1.0';
var displayName = "My Important Database";
var maxSize = 65536; // in bytes
var theDB = openDatabase(shortName, version, displayName, maxSize);
}
} catch(e) {
// Error Handling
if (e == "INVALID_STATE_ERR") {
// We have a version number mismatch
alert("Invalid database version");
} else {
// Unknown error
alert("Unknown error: " + e);
}
return;
}
// Assign the database to the global variable
my_DB = theDB;
}
// Create The Table
function createTable(thisDB) {
thisDB.transaction(function(txn) {
txn.executeSql('CREATE TABLE IF NOT EXISTS people (id unique, name, age)');
});
// The following line is the problem
someVar = txn;
}
Calling init_DB() works fine, and the database is created. However, calling createTable(my_DB) just fails silently, (No Errors, or Warnings) and the rest of the code completes, UNLESS I refer to "txn" somehow.
So adding the "SomeVar = txn;" line allows the Table to be created, but unfortunately, it causes "ReferenceError: Can't find variable: txn" to appear in the console, and stops the rest of the code from running.
Does anyone have any ideas? I've been trying to get this to work for over a week, and I'm at my wit's end.
Thanks in advance for any suggestions ;-)
N.B. Declaring "txn" before attempting to create a Table also causes a silent fail.
I'm using WCF data services in Windows phone 7, I want to save relational data in single click how could I do that?
it's think 2 table : Category and Products
I want to save data UI :
From Cateogry Table :-
CategoryId : (auto increment)
CategoryName : abc
From product Table :-
ProductId :-(auto increment)
CategoryId :- ? ( not sure how could I retrieve )
ProductsName : xyz
on button save click:
I want to insert above data in appropriated table , how could I do that?
I am using following code for add one table data :
try
{
context = new NorthwindEntities(NorthwindUri);
context.AddToProducts(product);
context.BeginSaveChanges(new AsyncCallback((result) =>
{
bool errorOccured = false;
// Use the Dispatcher to ensure that the
// asynchronous call returns in the correct thread.
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
context = result.AsyncState as NorthwindEntities;
try
{
// Complete the save changes operation and display the response.
DataServiceResponse response = context.EndSaveChanges(result);
foreach (ChangeOperationResponse changeResponse in response)
{
if (changeResponse.Error != null) errorOccured = true;
}
if (!errorOccured)
{
MessageBox.Show("The changes have been saved to the data service.");
}
else
{
MessageBox.Show("An error occured. One or more changes could not be saved.");
}
}
catch (Exception ex)
{
// Display the error from the response.
MessageBox.Show(string.Format("The following error occured: {0}", ex.Message));
}
});
}), context);
}
catch (Exception ex)
{
MessageBox.Show(string.Format("The changes could not be saved to the data service.\n"
+ "The following error occurred: {0}", ex.Message));
}
In OData relationships are not represented as foreign keys, instead they are represented as navigation properties. And then you manipulate them through manipulating links in the client library.
Take a look at this article: http://msdn.microsoft.com/en-us/library/dd756361(v=vs.103).aspx
You can call multiple methods which modify data and then call SaveChanges to send them all to the server.
Note though, that if the server requires referential integrity and you're for example adding two related entities at the same time, you might need to use SaveChanges(Batch) (which makes the client send everything in one request and thus allows the server to process it as a single transaction).
I am learning MVC2 and I am trying to create a data request management system. Somewhat like a ticketing system. A quick question, in my mvc controller class I have a post-create
[HttpPost]
public ActionResult Create(Request request)
{
if (ModelState.IsValid)
{
try
{
// TODO: Add insert logic here
var db = new DB();
db.Requests.InsertOnSubmit(request);
db.SubmitChanges();
return RedirectToAction("Index");
}
catch
{
return View(request);
}
}
else
{
return View(request);
}
}
Ok, this is extremely simple enough, well I add my view and once I create a row I get the 0 first in my Primary Key row. Then it will not increment anymore, I goto add another row and the catch returns me to the same view I am on. It seems that the primary key int id is not incrementing.
How do you auto increment the id (type int) here? I am a bit confused why MVC isn't handling this since it is the primary key type int. It will only make the first row with the id = 0 and that's all.
Your ID column needs to be set as an Identity column in the table in SQL server.
Also you should create your DB data context in a using:
using(var db = new DB())
{
db.Requests.InsertOnSubmit(request);
db.SubmitChanges();
return RedirectToAction("Index");
}
Otherwise you're spilling connections all over the place; and creating more memory leaks than an early build of windows (well, depending on your traffic ;) )