Monday, March 12, 2012

How to copy new data from server to a local database.

Can somebody tell me what is the easiest way to copy new data from MySQL database placed on server to a local Access 2003 DB on my computer? (Using Visual Basic 2005 PRO)

I want to copy whole rows (about 25 columns: strings, doubles, booleans and one BLOB).

Thanks

you need two connections that return two datatables once you have your datatables you can do something like this If the table schemas are the same :

MyAccessDT.Merge(MySQLDT)

Labels: , , , , , , , , , , ,

How to copy Modified Records In a DataSet to another Dataset??

I have created a dataset from database "DB1" table "T_DB1". I Loop throw the Dataset and make changes/modification tosome of the records. After that I try to update the Dataset.
Lets say the update fails because database is down. I would like to create a backup of the modified data in a different database so I can load it manually latter on in the real database.
I am currently going throw every row of the dataset and finding what has been modified and the inserting that record into the backup database.

... BUT Is there any better way of doing this?This forum is falling appart. Its not like it used to be.
There is a way to do this.

You simply have to dynamically change your SQL statement and connection.

Eg. If your using a SqlDataAdapter, just change the update command associated with it and set it's connection property to the new database. All rows that have been updated will call this function which will update your backup database... I would look something like this:

Try
'Update database (main database)

Catch ex as Exception

'Check exception, if database is down then...
newConnectionString = new sqlConnection(".....")
mySqlDataAdapter.UpdateCommand = new sqlcommand(newConnectionString)
UpdateCommand.commandtext = ".............."

'Update backup database

End Try


Thats right. Thanks

Labels: , , , , , , , , , , , , , ,

how to Copy Item one Gridview to another gridview

I have Two gridview left side where i populate data from Database and other will be empty at 1st time my requirement is when click any item and click to add button it will remove from that cell and add in to second gridview

same thing happens through drag and drop system Drag from one gridview to another well but it will be helpfull how to remove and add one gridview to another can someone give me idea

bye take care
regards
vikrant

Check out these links

http://forums.asp.net/p/1169459/1955946.aspx

http://www.codeproject.com/KB/HTML/SelectMoveRowsFromTables.aspx

Labels: , , , , , , , , , ,

How to copy an Access database using ADO.NET and C#??

Hi all,
I have an Access '97 database called "dbHLS", inside this database I have a
table called "tbHLS". I would like to copy the table tbHLS from within the
dbHLS.mdb to an Access 2002 database called "dbTarget". Obviously as I'm
copying the table tbHLS I dont want anything to do with the table to change
other than the location of it.
Can this be done? if so how can it be done' Anyone know of any links?
Thanks in advance.
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/Forums.aspx/dotnet-ado-net/200511/1On Fri, 18 Nov 2005 16:54:31 GMT, "Jon S via DotNetMonster.com" <u2272@.uwe> wrote:
¤ Hi all,
¤
¤ I have an Access '97 database called "dbHLS", inside this database I have a
¤ table called "tbHLS". I would like to copy the table tbHLS from within the
¤ dbHLS.mdb to an Access 2002 database called "dbTarget". Obviously as I'm
¤ copying the table tbHLS I dont want anything to do with the table to change
¤ other than the location of it.
¤
¤ Can this be done? if so how can it be done' Anyone know of any links?
The following code will create the table and copy the data. However, it will not create any indexes
or primary keys, etc.
Function ExportAccessToAccess() As Boolean
Dim AccessConn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;"
& _
"Data Source=e:\My Documents\dbHLS.mdb")
AccessConn.Open()
Dim AccessCommand As New System.Data.OleDb.OleDbCommand("SELECT * INTO [MS
Access;DATABASE=E:\My Documents\dbTarget.mdb;].[tbHLS] FROM tbHLS", AccessConn)
AccessCommand.ExecuteNonQuery()
AccessConn.Close()
Paul
~~~~
Microsoft MVP (Visual Basic)

Labels: , , , , , , , , ,

How to convert time format

Hi all,

I had query some time information from the database and use a dataset to bind to a GridView.

But unfortunately, the time that display on the GridView is not my desired choice.

It was display as "3/1/2007 10:06:27 PM".

Does anyone know how to convert it as "3/1/2007 22:06:27"?

Part of my code is as follow

pgDataAdapter.Fill(ds,

"Start Time");

Thanks

Hi bslim67,

You can use the DataFormatString property of the GridView column to format the datetime value.

Hope this helps.


Hi,

Hi,

I had tried this.

<asp:BoundFieldDataField="starttime"dataformatstring="{0:dd/MMM/yy}"

HeaderText

="Start Time"ReadOnly="True"SortExpression="starttime"/>

But when I run the program during runtime, it seems that it did not take effect.

It still show me the date and time though my dataformat is only on date.

Please help.

Thanks


Dear , friend:

You should set HtmlEncode=false in the markup of:BoundField

I hope the above information will be helpful. If you have any issues or concerns, please let me know. It's my pleasure to be of assistance


Hi,

Thanks for your info. It's really a great help for me.

Labels: , , , , , , , , , , ,

how to convert dBase Database to Access-SQL Database in ASP.Net

I'm developing a project which the data is output from other application (windows application) in form of dBase Database (DBF), i need to convert it into an access/sql data by using asp.net so i can manipulate. please anyone tell me how.

Thank you.

ApcYou could use ADO.NET and the ODBC or OleDb providers (as appropriate - I do not know what the status of drivers for dBase is these days).

At that point, just read it in and write it out...
I use OleDBConnection with Microsoft OLE DB Provider for ODBC Drivers with this properties :
- Use data source name : dBASE Files
- Enter the initial catalog to use : "myprojectpath"

but then I encounter this error :

"The .Net Data OLE DB Provider(System.Data.OleDb) does not support the MSDASQL
Provider, Microsoft OLE DB Provider for ODBC Drivers."

Can you tell me how to solve this problem.

Thank you.
Use the .NET ODBC provider. Using .NET 1.1, the ODBC provider should already be installed. It has classes that mirror SqlClient and OleDb.

Labels: , , , , , , , , , , , , ,

How to convert database MS Access to oracle?

How to convert database MS Access to oracle?

My database in MS access 2003. and i want to convert that database in to ORACLE 8i. please guide me for the same. thanks in advance.

You will have to do it manually.

First, create your tables in Oracle.
Next, Export your Access data to a CSV file.
Then use the Oracle command line took, Sql Loader to inport your data from the CSV file into your new Oracle tables.

No you don't.

There are tools by Oracle as well as all kinds of other vendors to do this automatically.

Start here:

http://www.oracle.com/technology/tech/migration/focusareas/access.html


ASPDavid wrote:

No you don't.

There are tools by Oracle as well as all kinds of other vendors to do this automatically.

Start here:

http://www.oracle.com/technology/tech/migration/focusareas/access.html


Thanks for the liink. I wasn't aware Oracle had a tool for importing Access files.

However, I don't ever recommend third-party tools since they involve $$$.
SQL Loader had worked fine for me for years.
dweezil.....can you be more specific...pls....
I have the same problem and I can't find a surce code aniware........can you help me with some....[-o<

BRUX wrote:

dweezil.....can you be more specific...pls....
I have the same problem and I can't find a surce code aniware........can you help me with some....[-o<


Export your Access database to a csv file or whatever file extension you want to use.
Create a corresponding table in Oracle.
Create a control for SQL*Loader:
Load Data
INFILE 'c:\mydatafile.csv
INTO table my_oracle_table_name
fields terminated by "," optionally enclosed by '"'
(
column_1,
column_2
)


Save the above control file as: access.ctl

Open a command prompt and type:
set oracle_sid = myoracle_sid
sqlldr username/password control= access.ctl log=mydatafile.log

Check the log file for any records that failed.

Also, look at Oracle's free developer tool,SQL Developer. I believe it has SQL*Loader funcitionality in it.

Good luck!

Labels: , , , , , , ,

How to convert a GridView Column into Hyperlink fields?

I am trying to display records from an SQL database using an ASP.Net GridView control but I would like for one of the columns to be a Hyperlink or Hyperlink fields. Im using a DataTable to get the info from the DB.
For example:

protected void Page_Load(object sender, EventArgs e)
{
string queryString = "SELECT * FROM Candidates";
connection.SelectQuery = queryString;
myTable = connection.get_Connection();//recive the data as DataTable
//
//May be something here to convert a specific column to an hyperlink.
//
GridView1.DataSource = myTable;
GridView1.DataBind();
myTable.Dispose();
}

You can convert the BoundField to a TemplateField:

For example:

<asp:TemplateFieldHeaderText="colName"><ItemTemplate><asp:HyperLinkrunat="server"ID="HyperLink2"NavigateUrl='<%# "mypage.aspx?Sample_ID=" & Eval("Sample_ID")& "&Count_ID=" & Eval("Count_ID")%>'Text='<%# Eval("colName")%>'></asp:HyperLink></ItemTemplate></asp:TemplateField>

You can also use a HyperLinkField. The DataTextField property is what is displayed. The DataNavigateUrlFields property is for anything you might need to add to the DataNavigateUrlFormatString property.

<asp:HyperLinkFieldDataTextField="ColumnName"DataNavigateUrlFields="ColumnName2"DataNavigateUrlFormatString="~/mypage.aspx?UserID={0}"HeaderText="Name"></asp:HyperLinkField>

Thank you maspr, I tryed it before and it creates a new column just like the one that I want to convert to hyperlinks, and actually it works but I dont want to show two columns (one regular and the same one like hyperlinks). Do you know a way to hide or make invisible the regular one?

thanks so much for your help.


Thanks Limno I just tryed that right now. The problem is that if i want to add the<asp:TemplateField> and then the hyperlink inside of it, first I need to create a <column> </column> tag on the GridView, but if I create a column, there will be two identical columns but one of them will be hyperlink and the other not. Maybe the conversion must be on the .cs file, to force the DataColum or the cell to be hyperlinks.
Actually, it is a very easy job to do. From the samrt tag, you use the Edit columns, Highlight the column you want to convert, and you can see there is a link on the right side says: "Convert this field into TemplateField". Click on it and put the code i showed you. You can play with it to make it fit your need. By the way, the TemplateField is very useful, you will need it from time to time for formating you databound controls (gridview, detailsview...). Let me know if I can help more. Thanks.

You can do it in the rowdatabound event of gridview if you like.

If e.Row.RowType = DataControlRowType.DataRowThen
Dim hlAsNew HyperLink
hl.NavigateUrl = "yoururl"
hl.Text = e.Row.Cells(indexOfYourColumn).Text
hl.Target ="daview" 'target frame for url
e.Row.Cells(indexOfYourColumn).Controls.Add(hl)

end if


But limno my GridView doesn't know which table it will recive because it is been fill dinamically by one Class that I create to make the connection and a method there return tha table as DataTable. So I cant use the Edit column to converti it. My DataBase isn't inside the project, I connect to it using a connection string which is hide on my connection class. This is why I think that the code must be on the C# files and not on the aspx ones. Any suggestions will be welcome.

P.S. I will post next the connection class and the code which recive the table.

Thanks a lot to all
Neozaid

This example do the connection to an access DB, I will change it later for the SQL one.

//This is my default.cs file
public partialclass _Default : System.Web.UI.Page
{
private Connection connection =new Connection();
private SortClass sorting =new SortClass();
private DataTable myTable;
private GridViewSortEventArgs column;

public _Default()
{
myTable =null;
}

protected void Page_Load(object sender, EventArgs e)
{
string queryString ="SELECT FirstName ... FROM Candidates";
connection.SelectQuery = queryString;
myTable = connection.get_Connection();//DataTable
GridViewCandidates.DataSource = myTable;
GridViewCandidates.DataBind();
myTable.Dispose();
}
}

////////////////////////////The next is the connection class/////////////////////////////////////

using System.Data.OleDb;public class Connection{private string selectQueryString;private OleDbDataReader readerDataReader;private OleDbCommand commandCommand =new OleDbCommand();private DataTable myDataTable;public Connection()//initialize the query string { selectQueryString =""; }//Here the class get or set the query to look on the DB. //If it don't have any query it will use the default one "".public string SelectQuery {get {return selectQueryString; }set { selectQueryString =value; } }//Method: make the connection to DB, & return the desired table.public DataTable get_Connection() {string connectionString ="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\\DB.mdb;"; OleDbConnection connConnection =new OleDbConnection(); connConnection.ConnectionString = connectionString; commandCommand.CommandText = SelectQuery; commandCommand.CommandType = CommandType.Text; commandCommand.Connection = connConnection; commandCommand.Connection.Open(); readerDataReader = commandCommand.ExecuteReader(CommandBehavior.CloseConnection); myDataTable =new DataTable(); myDataTable.Load(readerDataReader);//Dispose the objects. myDataTable.Dispose(); commandCommand.Dispose(); connConnection.Dispose();return myDataTable; }}
Sincerely,
Neozaid

Labels: , , , , , , , , , , , , ,