|
I am building an app that has a local MySQL DB and a master DB on an internet server. Basically the idea is to have a native version that can be used in the field. Yet, users can also use the master.
Does anyone know of code or an article that addresses such a scenario?
Any help is appreciated.
Thanks,
RABB17
|
|
|
|
|
I have done this specific scenario a few times and I hate it. The largest problem is with updates. If you can find a natural key solution then it is just a matter of copy paste and switching data sources. Really you can go into very complicated scenarios but they are fairly straight foward. Just try a few and see which one fits your scenario the best.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
Thanks for the encouragement! I was hoping it wasn't going to be as bad as I thought.
Have you found it's better to go with datetime comparisons for data?
Another avenue of thought is a seperate table specifically for changes. That way if two users update the same data before the main is updated, it leaves room for a decision. Of course with this comes the need for someone to approve changes. Easy when the data is small, but as use increases...
Thanks again for any help!
P.S. have you put any of your synch code out for public view?
RABB17
|
|
|
|
|
But it does sound like a good idea for an article.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
Hi, I am having trouble in updating my dataset, I create a dataset from a select command and display the details to a datagrid. I then goto the next new line in the datagrid and insert some new details then click the insertRow button (code below) and I get the following error message :-
the exception which is caught states : - "Value cannot be null. Parameter name: dataset"
I am not up to scratch with datasets, but all examples I can find of updates are where only one line of the dataset is shown at a time in text boxes and then a blank set of textboxes are displayed to add a new row then convert the textboxes.text to the add row command, but I am creating an application to be a front end to a database so none of the columns are known so I cannot create this form of input as the amount of textboxes would never be known.
Please help
Many thanks
John
Code for updating dataset
[CODE] Private Sub btnInsertRow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInsertRow.Click
Dim dset As DataSet
tblName = (cmbInsertData.Text)
dbConn.openExistingDatabse("Data Source=" & getDBName() & ";Version=3;New=False;Compress=True;")
dbConn.createSQLCommand()
Try
dbConn.updateDataSet(dset, tblName)
Catch es As Exception
MessageBox.Show(es.Message)
End Try
End Sub[/CODE]
[CODE] Public Sub updateDataSet(ByVal dset As DataSet, ByVal tableName As String)
Dim sqlite_dataAdapter As SQLiteDataAdapter = New SQLiteDataAdapter()
sqlite_commandBuilder = New SQLiteCommandBuilder(sqlite_dataAdapter)
sqlite_dataAdapter.Update(dset, tableName)
End Sub[/CODE]
|
|
|
|
|
You could try disabling the constraints on your dataset (temporarily). DataSet.EnforceConstraints = false ;
Usually I like to create a new DataRow, and populate it with default values, and then insert the DataRow into the appropriate DataTable. If your grid is bound to the DataSet, then the new row will automatically appear in the grid.
|
|
|
|
|
Hi, thanks foryour advice, I havesince managed to get the dataset working.
Many thanks
John
|
|
|
|
|
Recently I've dropped one table which has around 100 records.
I want to restore those 100 records.
Is there any log maintained which will give me those deleted tuples of that
table (
|
|
|
|
|
You need to restore a back up of the database to a new database with a different name and copy the data from there.
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|
|
I can connect to it and get the column names, etc.
But it doesn't retrieve any records and I don't know why!
I have tried a few different ways, but nothing seems to work.
What am I doing wrong??
Here's my code:
// string query = @"SELECT * FROM CONNTEST\FLOW_1";
string DBConnection = @"Provider=WinCCOLEDBProvider.1;DataSource=Laptop\WinCC;Catalog=CC_Connecti_06_07_29_15_50_04R;";
string SqlStr = @"TAG:R,'CONNTEST\FLOW_1','0000-00-00 00:10:00.000','0000-00-00'";
//string SqlStr = @"TAG:R,'CONNTEST\FLOW_1','0000-00-00 00:30:00.000','0000-00-00 00:00:00.000'";
// TAG:R,'CONNTEST\FLOW_1','0000-00-00 00:30:00.000','0000-00-00 00:00:00.000'
//string SqlStr = "TAG:R,1,'0000-00-00 00:30:00.000','0000-00-00 00:00:00.000'";
//Open Recordset via Connection object.
//string SqlStr = @"TAG:R,'CONNTEST\FLOW_1','0000-00-00 00:01:00','0000-00-00 00:00:00";
// 1: Make Connection to Database
ADODB.ConnectionClass Conn = new ADODB.ConnectionClass();
Conn.ConnectionString = DBConnection;
Conn.CursorLocation = CursorLocationEnum.adUseServer;
Conn.Open(DBConnection, "", "", 0);
// Conn = Server.CreateObject("ADODB.Connection");
// 2: Use the command text query
ADODB.CommandClass OCom = new ADODB.CommandClass ();
OCom.CommandType = ADODB.CommandTypeEnum.adCmdText;
OCom.ActiveConnection = Conn;
OCom.CommandText = SqlStr;
// 3: Create the RecordSet and fill with the data
//'ADODB.RecordsetClass rs = new ADODB.RecordsetClass();
//rs.Open(SqlStr,DBConnection,ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic, -1);
//'rs.Open(OCom, Type.Missing, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockBatchOptimistic, -1);
object dummy = Type.Missing;
ADODB.Recordset rs = OCom.Execute(out dummy, ref dummy, 0);
object GetName;
GetName = rs.RecordCount;
////////GetName = rs.Fields[1].Value;
|
|
|
|
|
What you need is three tables. tblRecipes, tblIngredients and tblRecipeIngredients.
tblRecipes should be keyed on RecipeID
tblIngredients should be keyed on IngredientID
tblRecipeIngredients should have a dual key of RecipeID and IngredientID
Then you can look up recipe by ingredient or ingredient by recipe.
Simple.
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|
|
Hello,
Thanks for your comments.
I think your advice will do the job but have problems creating the relation between two tables. I get the error "can not create a child list for field RelationName". I get this when it is trying to bind the relation to a GridBox.
Any idea what went wrong?
Do you think it might be that i am using the names column of the recipes and the ingredients tables as my key?
george
|
|
|
|
|
Hello, could somebody tell me how to configure Zone Alarm so that it would allow remote connections to SQLServer 2005 express?
R
Johan
|
|
|
|
|
I want to create a stored procedure that select certain fields from one databases, and somemore from another these databases are on 2 different servers but run the same sql server 2000. if anyone can help point me in the right direction i would much appreciate it.
|
|
|
|
|
There is no sql server 2003. It is 2000 or 2005. Check the Books on line for setting up a linked server. You can add a linked server from enterprise manager and then access the linked server via t-sql.
select * from server.database.owner.table
Make sure the MSDTC (distributed transaction coordinator) service is running on your servers.
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|
|
Hi frends
I have written a trigger in MS-SQL 2000 runing successfully to insert single row.....but if i need to insert multiple rows from a select query in this trigger ......I am Confused ?
Purpose of Trigger
whenever a column will be updated in a table the data from two tables will be inserted into two tables where one table has multiple rows to insert.
I am trying to use While loop but confused that what should be the condition there to break tha loop......pls help if someone knows.
My trigger is
IF (COLUMNS_UPDATED() ) > 49
BEGIN
Declare @ServerDate datetime;
Declare @TranID numeric(18,0);
Declare @OppID numeric(18,0);
Declare @ProductID int;
Declare @Qty int;
Declare @Cost numeric(18,2);
Declare @Price numeric(18,2);
Declare @Discount numeric(18,2);
Declare @TaxAmt numeric(18,2);
Declare @UserID numeric(18,0);
Declare @ContactID numeric(18,0)
Declare @CountProduct int
SELECT @ServerDate=getdate()
SELECT @OppID=Opp.OppId, @ContactID=Opp.ContactID, @UserID=Opp.UserID FROM Opportunity Opp INNER JOIN INSERTED ON Opp.OppId = INSERTED.OppId where Inserted.StatusID=3
if (Convert(varchar(10),@OppID) != '')
BEGIN
INSERT INTO [Transaction] (OppID,TranDate, ContactID,UserID) values (@OppId, @ServerDate, @ContactID, @UserID)
SELECT @TranID=TranID from [Transaction] where TranDate=@ServerDate
SELECT @ProductID=Opp.ProductID, @Qty=Opp.Qty, @Cost=Opp.Cost, @Price=Opp.Price, @Discount=Opp.Discount, @TaxAmt=Opp.TaxAmt FROM vOpportunityList Opp INNER JOIN INSERTED ON Opp.OppId = INSERTED.OppId where Inserted.StatusID=3
--Count row
SELECT @CountProduct=count(Opp.ProductID) FROM vOpportunityList Opp INNER JOIN INSERTED ON Opp.OppId = INSERTED.OppId where Inserted.StatusID=3
--WHILE (-----------)
--BEGIN
INSERT INTO [TranProduct] (TranID,ProductID,Qty,Cost,Price,Discount,TaxAmt) values(@TranID, @ProductID, @Qty, @Cost, @Price, @Discount, @TaxAmt)
--END
END
END
Dinesh Sharma
|
|
|
|
|
I would suggest a cursor but using a cursor in a trigger is bad practice as it will be slow. Is there no way to do this update from your application inside of commitment control? If a trigger is your only option then use a cursor to do the loop. You don't need a row count variable either just loop through the results of your select statement. Check Here
for more info.
how vital enterprise application are for proactive organizations leveraging collective synergy to think outside the box and formulate their key objectives into a win-win game plan with a quality-driven approach that focuses on empowering key players to drive-up their core competencies and increase expectations with an all-around initiative to drive up the bottom-line. But of course, that's all a "high level" overview of things
--thedailywtf 3/21/06
|
|
|
|
|
Thanks ToddHileHoffer
I done this and now its working properly...
Thanks a lot
Dinesh Sharma
Dinesh Sharma
|
|
|
|
|
Hi all,
Well first of all, I would like to know if it is possible to put sql scripting in a batch file for execution?
I can connect to the MySql Server with a batch file but can't execute anymore commands (MySql command like reading from a file). I don't know how to do this, so If anyone could point me to a site or help me .... well just thanx in advance
Regards
Programm3r
|
|
|
|
|
Hi all,
Well first of all, I would like to know if it is possible to put sql scripting in a batch file for execution?
I can connect to the MySql Server with a batch file but can't execute anymore commands (MySql command like reading from a file). I don't know how to do this, so If anyone could point me to a site or help me .... well just thanx in advance
Regards
Programm3r
|
|
|
|
|
You can use the osql command to execute the sql commands from the batch fils.
thanks,
SeEa
|
|
|
|
|
Hi everyone!
I have an Access table made up of various "ingredients". From this table by selecting various "ingredients" i want to create another table (or just create new entries in another table) of "recipe" names and store this table in the same or another Access file.
I am connecting to the ingredients table and filling a dataset with it, through a DataAdapter, then i'm displaying the contents in a DataGrid in which i've added a CheckBox column. I'm planning to use this checkbox column to select the ingredients for the various recipes.
I know i can link such tables by using a column in the ingredients table which will specify a recipe name for each ingredient. However my problem is that some of the recipes will share the same ingredients so i can't use such a column to create the relationship.
Any ideas on the way to tackle this problem?
Thanks in advance.
george
|
|
|
|
|
I get this message when running an application from a remote computer with standard connection.
SELECT permission denied on object 'custGroups', database 'ValkyriaDB', schema 'dbo'
I have SQL 2005 express database and MS SQL server managament studio express.
I done this so far:
In the security - logins - 'USER' - properties i have mapped my username to the correct db (default db) and in user mappings for that db i have granted all database roles to my username. The default scheme is dbo.
For the valkyriaDB schemes - dbo i have granted (Grant and With Grant) all permissions.
I simply dont understand why i get this error message... Must be something i dont understand.
Please advice
PS. It is much easier with old MSDN, or any opensource DB, dont understand why it has to be so hard with MS.
|
|
|
|
|
ITs not hard with MS it just enforces strong security.
Check you can access the object through a query using the 'USER' and debug from there. You might want to specifiy the db in your connection string as well as speficing the instance name mymachine\SQLEXPRESS
Look where you want to go not where you don't want to crash.
Bikers Bible
|
|
|
|
|
Thx, it helped, but now i got a new problem. Now it suddenly says:
System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
But still i can do connection.Open() from remote, i just can execute any statements. Where can i check if the server is set to receive remote connections?
BTW, my connection String:
="Server=MACHINENAME\SQLEXPRESS;Database=ValkyriaDB;UserID=XXXX;Password=XXX;Trusted_Connection=False;"
Thx for previous anserw, im new to SQL2005 or any MS database...
-- modified at 5:06 Tuesday 1st August, 2006
|
|
|
|
|