Monday, March 12, 2012

how to convert to sqltype?

For example there is a DataTable dt and the first column in the firstrow is type of string, I want to assign it to SqlString as following:

SqlString s = (SqlString)dt.Rows[0][0];

The above code throws "Invalid cast" exception. My question is how tocast it to SqlString in this case? In general, how about cast othertypes? such as if the second column in the first row is type ofdecimal, then how to cast it to SqlDecimal?

SqlDecimal d ? dt.Rows[0][1]

Thanks.

I think you could do:

SqlString s = new SqlString(dt.Rows[0][0].ToString());

I'm curious why you're wanting to work with it as a SqlString?

Marcie

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 text in GridView col into a hyperlink?

Hi,

One of the fields in a GridView control contains a unc path to a local area network folder [eg:\\servername\foldername].

Each record in the GridView may have a path to a different folder.

I would like to be able to click on the path in the GridView and have the folder open - instead of having to copy the text into the Start | Run dialog box of my pc.

I've looked at converting the column into a hyperlink control [by making it a Templated control] & I've tried this code:

<Columns>
<asp:hyperlinkfield datatextfield="Path"
datanavigateurlformatstring="Path"/>
<asp:BoundField DataField="Path"
HeaderText="Online"
SortExpression="Path" />
</Columns>

. . . and I get an error because the app is trying to open a folder in the directory where the web site resides rather than the folder that is indicated in the path [Text] in the column.

I'm trying to figure out how to tell asp.net to open the folder indicated by the unc path in the field . . .Confused

I'd appreciate any help I can get.

Thanks!

Robin

What most likely is happening, is all links in a website by default are relative, so you end up with a link to something like this

http://localhost:12345:\\servername\path

Which obviously isnt going to work. You can fix it by prefixing it with something it recognizes as a file path, rather than a relative path.


Try replacing your <asp:HyperLink /> with this:

<Columns>

<asp:TemplateField>

<ItemTemplate>

<asp:HyperLinkText="TextField"id="myHL"runat="server"

NavigateUrl='<%# "file:///" + DataBinder.Eval(Container.DataItem, "Path").ToString() %>'></asp:HyperLink>

</ItemTemplate>

</asp:TemplateField>

</Columns>

Thanks, Hans! That worked.

I have one more question, though. In the Text = "TextField" - I would like the text that displays be the actual path that is coming in from the database.

So - instead of TextField [hard-coded literal] in the GridView I'd like it to have something like this -\\ServerName\FolderName [what is in the field for each record].

How would I do that?

Robin


Text='<%# Databinder.Eval(Container.DataITem, "Path").tostring() %>'


Thanks, Bryan. Perfect! I tried playing around with that line of code from Hans . . .

Robin

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

How to convert 'System.String' to 'System.Guid'

prm = new SqlParameter("@dotnet.itags.org.passkey", SqlDbType.UniqueIdentifier);
prm.Value = stringvalue;
I got this exception
Invalid cast from 'System.String' to 'System.Guid'
--
Arne Garvander
(I program VB.Net for fun and C# to get paid.)prm.Value = new Guid(stringvalue);
"Arne Garvander" <ArneGarvander@.discussions.microsoft.com> wrote in message
news:ACDE0382-BBD1-4AC8-9D99-55445B9F6F49@.microsoft.com...
> prm = new SqlParameter("@.passkey", SqlDbType.UniqueIdentifier);
> prm.Value = stringvalue;
> I got this exception
> Invalid cast from 'System.String' to 'System.Guid'
> --
> Arne Garvander
> (I program VB.Net for fun and C# to get paid.)

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

How to convert strings yymmdd (example: 060120) into regular dates (example: 01/20/06)?

I just want to do this for displaying the data using a gridview. I am working with VB.NET.

The dates need to be saved as they are (strings = yymmdd. example: 060911) so I do not want to save how the are saved in the SQL database.

But I want to display them using the gridview in the standard date format ('mm/dd/yyyy' or 'mm/dd/yy') so I will need to convert them.


I would like to know which would be a nice way to accomplish this, thanks for any suggestions.

another thing i would like to know how to do is to convert another field from the same gridview from string: (example: '2295' into formated amounts (example: $22.95) I do not care wether they are numeric or strings, because I just want it for displaying the data in the gridview. But also these values are saved without the decimal point, for example 10099, should be converted to $100.99 or 150089 should become $1,500.89

Thanks for suggestions.

remember I do not want to change or save this data into the database, because it is supposed to be saved as it is. But I do want to be able to show the user the data in the appropiate format.

The thing is that I do not know how or where to write the code to tell the gridview to convert it how I want it.

This will convert your date to a DateTime object

DateTime.ParseExact("060708","yymmdd", System.Globalization.CultureInfo.CurrentCulture ,System.Globalization.DateTimeStyles.None)

You can handle the RowDataBound event find the label you are displaying it in and set it to something like

mylabel.Text = DateTime.ParseExact("060708","yymmdd", System.Globalization.CultureInfo.CurrentCulture ,System.Globalization.DateTimeStyles.None).ToString("mm/dd/yyy")


I need help doing the rowdatabound for doing that formating

Protected Sub GridView1_RowDataBound(ByVal senderAs Object,ByVal eAs System.Web.UI.WebControls.GridViewRowEventArgs)Handles GridView1.RowDataBoundTry If e.Row.RowType = DataControlRowType.DataRowThen Dim DollarAmountAs Label =CType(e.Row.FindControl("Label"), Label)
'Here I want to format the current string.text attribute. (how can i do it?)End If Catch End Try End Sub

You can try the solution above;

dim temp as string= DollarAmount.Text

DollarAmount.Text = DateTime.ParseExact(temp,"yymmdd", System.Globalization.CultureInfo.CurrentCulture ,System.Globalization.DateTimeStyles.None).ToString("mm/dd/yyy")


Thanks,Big Smile

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

How to convert string to int n gridview colors?

1st question on vb how do i convert string to int?

2nd question

eg.

GridView1.BorderColor = Drawing.Color.Aqua

its set on vb script but what i want to know is how to make it use color codes for eg. GridView1.BorderColor = #FFFFFF

thank you

Answer 1:

You can use either

int myInt =Integer.Parse(myString)

or

Dim myIntAs IntegerIf Integer.TryParse(myString,out myIntThen Return IntegerElse Return 0End If

Answer 2,

Dim cAs System.Drawing.Color = System.Drawing.ColorTranslator.FromHtml("#F5F7F8")Dim strHtmlColorAs String = System.Drawing.ColorTranslator.ToHtml(c)

1) Have a look at the Cint, Convert.ToInt16, Integer.Parse or Integer.TryParse methods

2) System.Drawing.Color.FromName("#FFFFFF")

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

How to convert string data into time format

I have some of the old data looks like this. And this is time data.

144601
170320
083345

I wanted to convert this in proper format as time with AM, PM etc. and display in GridView column.

Currently this data is displaying as it is in one of the GridView column

Please help out..

thanks

Public Function stringtodate(ByVal strdate As String) Dim tempdt As Date tempdt = Convert.ToDateTime(strdate) Dim format1 As String Dim en As New CultureInfo("en-AU") format1 = "MM/dd/yyyy HH:mm:ss" Dim dtstring As String dtstring = tempdt.ToString(format1) tempdt = DateTime.ParseExact(dtstring, format1, en.DateTimeFormat) Return tempdt End Function

you can specify the format as u need.

How do I call this function in gridview, to display the data in one of the column of the grid view. ?


Use Bound column of grid.Now in datafield property try to bind the data using a literal.

<asp:literal id="datevar" runat="server">

<asp:grid>

<asp:boundcolumn ......datafield=<%= datevar %>

</asp:grid>

Now in code behind try to bind the your date value by calling that function to the datevar literal in grid_databound event.

Labels: , , , , , , , ,

how to convert sqldatasource to other type like dataview, dataset or datareader

Hi all,

i have got many problems with sqldatasource and dataview

--------------------------------
string ConnectionString = "Server=server;Integrated
Security=True;Database=contest;Persist Security Info=True";

string QueryString = "SELECT * FROM [members]";

System.Web.UI.WebControls.SqlDataSource SqlDataSource = new System.Web.UI.WebControls.SqlDataSource();

SqlDataSource.ConnectionString = ConnectionString;
SqlDataSource.SelectCommand = QueryString;
SqlDataSource.DataSourceMode = System.Web.UI.WebControls.SqlDataSourceMode.DataSet;

DataView dv = new DataView();

dv = (DataView)SqlDataSource;
--------------------------------

CS0030: Cannot convert type 'System.Web.UI.WebControls.SqlDataSource' to 'System.Data.DataView'

--------------------------------

i got similar problems if i use DataSet and DataReader.
SqlDataSource.DataSourceMode = System.Web.UI.WebControls.SqlDataSourceMode.DataSet;
SqlDataSource.DataSourceMode = System.Web.UI.WebControls.SqlDataSourceMode.DataReader;

--------------------------------

thx a lot.To return the DataSet from the SqlDataSource you have to use the SqlDataSource Select method. The Select method will return a DataView if the DataSourceMode of the SqlDataSource is set to System.Web.UI.WebControls.SqlDataSourceMode.DataSet.

If you set the mode to System.Web.UI.WebControls.SqlDataSourceMode.DataReader. A DataReader will be returned.
thx,
but, i dont know how to use sqldatasource as dataview after set it to dataset.
u have an example ?
thx
What is your purpose with the code? Do you only want to access a data source and get a Dataset back? If so I should recommend you to use SqlDataAdaptar:


DataSet ds = new DataSet();

using(SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM Employees", myConnectionString))
{
adapter.Fill(ds);
}

If you want to use SqlDataSource for some reason, here is an example:


string ConnectionString = "Server=localhost;Integrated Security=True;Database=Northwind;User=****;password=****;";
string QueryString = "SELECT * FROM [Employees]";
System.Web.UI.WebControls.SqlDataSource SqlDataSource = new System.Web.UI.WebControls.SqlDataSource();
SqlDataSource.ConnectionString = ConnectionString;
SqlDataSource.SelectCommand = QueryString;

DataSourceSelectArguments arg = new DataSourceSelectArguments();
System.Data.DataView dv = (System.Data.DataView)SqlDataSource.Select(arg);


okay thanks, now continuing on with system.data.dataview dv = ..., how do you retrieve a value, can you finish the code for us?
Many thanks,
Asaf

Here is the thing

DataView dv ;

dv = (DataView)DsOpenOrders.Select(DataSourceSelectArguments.Empty);

dv.Sort = SortField;

return dv;

DsOpenOrders is the SqlDataSource.

THis will help you I guess.

Thanks
Suda

Labels: , , , , , , , , ,

How to convert SqlDatareader to DataTable

Hello all,

Is there a way to convert a SqlDatareader to DataTable?

I'm not talking about looping through the datareader and add each value into the datatable. For example the dataset, you use a DataAdapter to fill the data into the dataset.

I've read on something like a ovrride the fill function and of the DbDataAdapter ... but it doesn't seem to work ...

protected overridable function(dataTable as DataTable, dataReader as IDataReader) as integer
return Fill(dataTable, dataReader)
end function

Has anyone done this before? Any input is appreciated.

Unfortunately, as far as I know, the answer is no - due to the inherent nature of a DataReader itself. It's a forward only/read once process. If you don't do something with it at the time it's being created, it's gone.

The only way I can think of to take care of that, would be to manually insert the objects into the datatable, as the datareader was being read


David, your icon is scary ... lol. thanks for the respond. please take a peek at this URL:http://msdn2.microsoft.com/en-us/library/497b1k4t.aspx

and also this sample:http://www.eggheadcafe.com/PrintSearchContent.asp?LINKID=628

I tried but somehow I can't get it to run. Well, I didn't copy all of the author's code. What do you think?

Labels: , , , , , , , ,

how to convert objectdatasource to dataView?

hi there...does anyone run into a problem where the objectdatasource cannot be casting into dataview? it aleays works for me except for this time

.csDataView dv = (DataView)objSubCategoriesByUserPermissions.Select();.aspx<asp:ObjectDataSource ID="objSubCategoriesByUserPermissions" runat="server" SelectMethod="GetCategoryByUserPermissions" TypeName="MB.TheBeerHouse.BLL.Articles.Category"> <SelectParameters> <asp:QueryStringParameter Name="articleID" QueryStringField="ID" DefaultValue="-1" /> <asp:ProfileParameter Name="username" PropertyName="username" /> </SelectParameters> </asp:ObjectDataSource> <br /> <asp:SqlDataSource ID="sdcAllCategories" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString%>" SelectCommand="SELECT CategoryID, Title FROM tbh_Categories WHERE (visible = 1) AND (ParentID IS NULL)"> </asp:SqlDataSource>

Unable to cast object of type 'System.Object[]' to type 'System.Data.DataView'.

Hi

ObjectDataSource.select() must return one of the types listed below:

IEnumerable

TheIEnumerable is returned by theSelect method.

DataTable

ADataView is created by using theDataTable and returned by theSelect method.

DataView

TheDataView is returned by theSelect method.

DataSet

The firstDataTable of theDataSet is extracted and aDataView is created and returned by theSelect method.

Object

The object is wrapped in a one-elementIEnumerable collection and returned by theSelect method.

Here is a similar thread that may give you clue:http://forums.asp.net/thread/1491464.aspx

For details about ObjectDataSource.select() seehttp://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.objectdatasource.select.aspx

Hope this helps.


thank it does.

Labels: , , , , , , ,

How to convert lower case to upper case

Hi everyone

How can I convert lower case to upper case when i type inside a textbox

Please provide me with vb.net code

Do you mean you want to convert it as it is being typed? Or once you receive it on the server-side?

If the latter, use the string.ToUpper() method in VB.NET.http://support.microsoft.com/kb/312897 If the former, you can use the javascript ToUppercase() method in conjunction with the onkeypress event for the textbox in question.http://jennifermadden.com/javascript/stringUpperLower.html


To achieve this on the Client side try this:

add this to your Code behind (VB.net):

ProtectedSub Page_Load(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.Load

TextBox1.Attributes.Add("onkeyup","toUppercase()")

EndSub

Then in your HTML markup:

<headrunat="server">
<script
>
function
toUppercase() {
document.form1.TextBox1.value = document.form1.TextBox1.value.toUpperCase();
}
</script
>
</head
>
<body
>
<formid="form1"runat
="server">
<div
>
<asp:TextBoxID="TextBox1"runat="server"></asp:TextBox
>
</div
>
</form
>
</body
>

If you want to do this Server Side (VB.net):

TextBox1.Text = TextBox1.Text.ToUpper



you can use style instead..

<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
.test
{
text-transform: uppercase;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div
</div>
<asp:TextBox ID="TextBox1" runat="server" CssClass="test"></asp:TextBox>
</form>
</body>


kaushalparik27:

you can use style instead..

 .test
{
text-transform: uppercase;
}

That won't convert it. It will only change the way it appears on a web page. If you look at the source of the page where your style is used, you will see that the case of the text is still in its original state.


It works, but it saves the data with lower case in the database


have you tried this:

scott@.elbandit.co.uk:

To achieve this on the Client side try this:

add this to your Code behind (VB.net):

ProtectedSub Page_Load(ByVal senderAsObject,ByVal eAs System.EventArgs)HandlesMe.Load

TextBox1.Attributes.Add("onkeyup","toUppercase()")

EndSub

Then in your HTML markup:

<headrunat="server">
<script
>
function
toUppercase() {
document.form1.TextBox1.value = document.form1.TextBox1.value.toUpperCase();
}
</script
>
</head
>
<body
>
<formid="form1"runat
="server">
<div
>
<asp:TextBoxID="TextBox1"runat="server"></asp:TextBox
>
</div
>
</form
>
</body
>

If you want to do this Server Side (VB.net):

TextBox1.Text = TextBox1.Text.ToUpper



pam.rose:

but it saves the data with lower case in the database

but at the time of saving in the database.. simply .ToString().ToUpper() can be used...

Labels: , , , , , , , , ,

How to convert from UserId to UserName in GridView?

i am using membership, and my GridView are using by choosing ObjectDataSource , In my ObjectDataSource i am using UserId, but when show the GridView i want the UserId changer UserName.How to do it? For example my some code,

<asp:TemplateField HeaderText="UserId"><ItemTemplate><%#Eval("UserId")%></ItemTemplate></asp:TemplateField>

You could write method that calls

MembershipUser u =Membership.GetUser(userID);.

username = u.UserName

Then call it from the template with <%# (String) MyGetUserNameMethod(String userid) %>

(declare the function protected string MyGetUseNameMethod in your code behind class)


Dear Sir,

Sorry i still can not understand!


hi

try this

<asp:TemplateField> <ItemTemplate><%#Membership.GetUser(Eval("UserId")).UserName%> </ItemTemplate> </asp:TemplateField>

Dear Sir,

Still can not!


hi

just replace your code with the one i gave you

so delete your templateField column and put my code

man if you still dont understand ,

could you explain what is the things that makes you confused

thanks


Dear Sir,

Thank!!it working,Sorry Sir, maybe just now i am typing wrong, Now, i am no error, Finally Thank you Sir!!!

Labels: , , , , , , , ,

How to Convert from OleDbParametersCollection to OleDbParameter[] array?

I am trying to convert from OleDbParametersCollection object to OleDbParameter[] array. How to perform this operation(ConvertToOleDbParameter())?

What is the problem with the following code? :

Code Snippet

private OleDbParameter[] ConvertToOleDbParameter(OleDbParameterCollection paramCollection)

{

OleDbParameter[] paramArray = new OleDbParameter[paramCollection.Count];

OleDbParameter param = new OleDbParameter();

paramArray.Initialize();

IEnumerator enumParams = paramCollection.GetEnumerator();

for (int i = 0; i < paramCollection.Count; i++)

{

try

{

enumParams.MoveNext();

param = (OleDbParameter) enumParams.Current;

paramArray[i] = param;

}

catch (Exception e)

{

MessageBox.Show(e.Message);

}

}

return paramArray;

}

So, when I do following:

Code Snippet

//....

try

{

OleDbParameter[] arrParams = ConvertToOleDbParameter(paramCollection);

oleCommand.Parameters.AddRange(arrParams);

oleCommand.ExecuteNonQuery();

return true;

}

catch (Exception exc)

{

System.Windows.Forms.MessageBox.Show(exc.Message);

return false;

}

The above throws the following exception:

The OleDbParameter is already contained by another OleDbParameterCollection.

I would appreciate your help.

Thanks.

oleCommand.Parameters is also a OledDbParameterCollection. Your conversion method merely returns an array whose elements are references of the existing parameters in paramCollection. The AddRange() call tries to add those parameters in paramCollection to another parametercollection (oleCommand.Parameters).

The error message tells you that for any parameter, it can only belong to one parametercollection.

Labels: , , , , , , , , ,

How to convert empty string to Null of Datetime data type

Hi,
This is very annoying to me.
I have a datatable which has two fields of DateTime data type. Both of them are nullable. When I do the update to that datatable, in some cases, Null values are going be put through TextBox and DropDownList's selected Item. But the updated value in database is 01/01/1900 and 12:00 AM which is not the real null value, can anyone help me with this?
My update code:

Dim inputDateAsNewDate
Dim inputSessionAsNewDate

If Trim(txtDate.Text) <> ""Then
inputDate = Convert.ToDateTime(txtDate.Text)
Else
inputDate = System.Data.SqlTypes.SqlDateTime.Null -->01/01/1900
EndIf

If ddlSession.SelectedItem.Text <> ""Then
inputSession = Convert.ToDateTime(ddlSession.SelectedItem.Text)
Else
inputSession = System.Data.SqlTypes.SqlDateTime.Null -->12:00 AM
EndIf

UpdateDT(AgendaItemID, inputDate, inputSession)

Just out of interest, why aren't inputSession and input of type Date System.Data.SqlTypes.SqlDateTime?
If you use the standard CLR DateTime structure, it will also run back to its default value as that's all it can hold.
Make the variables of the appropriate type and then convert the input into SqlDateTime, not the other way around, and your problem should go away.

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 dataset to xml string with embedded schema

I have been trying to find a way to get an xml string with embedded schema from a dataset.

I know that you can use the .getxml and .getschema functions on the dataset but I do not see an easy way of combining those two results into one valid xml string.

I can't save anything to disk, everything has to happen in memory. I thought of using the .writexml method but you cannot use .writexml and pass a string...

Thank you for any thoughts you might have to solve this problem I am having.

Robertmaybe u can use the XmlSerializer object?

Labels: , , , , , , , , ,

How to convert datareader.items value to integer

Hi,

I have a datareader item

myreader.Item("netcost")

This is a numeric value, I need to take the value and minus 500 from it, I have

(myreader.Item("netcost")-500)

This causes an error, 'cannot cast from string to integer'

How do I do it?

Thanks. BenYou can use Ctype.

For example, this converts you datareader item to an integer.

CType(myreader.Item("netcost"),Integer) - 500
Convert.ToInt32(myreader.Item("netcost").ToString())

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

how to convert DataColumn to string array

Dear friends,

How to convert DataColumn to String Array

I have a set of values in DataColumn that values should be transferred to String Array. Is there any sort way without using looping statement.

Thanks.

I think there is no other alternative than looping the table .. a similar stuff is discussed and can be used

http://dotnet.org.za/keithrull/archive/2006/01/13/38913.aspx


Hi,

If you just need to get the values in each DataColumn in a DataRow, there is an ItemArray property for DataRow class. You can go through each row and call DataRow.ItemArray property to get it.

Here is a link for more information

http://msdn2.microsoft.com/en-us/library/system.data.datarow.itemarray.aspx

HTH. If this does not answer your question, please feel free to mark the post as Not Answered and reply. Thank you!

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 Class object into DataSet?

Lets say, I have a following XSD utility generated class as follows:

[XmlRoot(Namespace="http://example.com/2007/ex1")]
public class Example {
public Example () {}
public string Name;
public int Power;
}

I have to pull data from several tables(MS Access2003) and store it in a DataSet.

Now, Is it possible to use it like:

Example example = new Example();
example.Power = 42;
example.Name = "Kibo";
DataSet myDataSet = new DataSet();
myDataSet = example;

or

myDataSet.Add(example);

Somehow, to add the example object tree in myDataSet, and pull values from tables directly into myDataSet.

This will help me in doing following things:

1. I'd not need to change my existing XSD generated class structure into DataSet.

2. Pull data directly into the DataSet, using explicit queries

3. Generate the Xml file directly.

Any help/idea/pointer/etc would help Alot.

Thanks.

The sample code you have given shouldn't work cause a DataSet can't load data from an custom entity object.

Check this site for more details:

http://msdn2.microsoft.com/en-us/library/ekw4dh3f(VS.80).aspx

http://msdn2.microsoft.com/en-us/library/ekw4dh3f(VS.80).aspx

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