|
Thank you very much!! That was the solution!!
Spiros Prantalos
Miami the place to be!!
|
|
|
|
|
The problem I have is as follows:
I have a large number of classes (each having different data members, over 300) which I wish to store the member data within a data blob in a SQL DB (Just one data table). The DB table has the class type and a data blob. Upon retriving the data from the table, the class type is viewed to determine which class to address, and then call the class to extract the data blob. In C++ I would have used a memcpy(), is there a good way of creating and extracting the data blobs, or equiverant to memcpy without having to use unmanaged code.
|
|
|
|
|
Hi
i am newbee in ADO .NET , just curious to know ,whats equivalent to cursor in ADO .NET or how does ADO .NET uses Cursor and LOCKS !!
P.S. PATWAL
|
|
|
|
|
i need to insert huge database in sql table
the problem
1) i need to know any method/process by which u may guess the connection has break
2) if connection is brek i need to roll back all the inserts
any idea ?
P.S. PATWAL
|
|
|
|
|
First of all, you didn't mention how you contact your database and what db you use (or do you mean MS SQL-Server by "sql table"?)
1) Can't say any particular without knowing how you contact database. But you could check the return value of your data-access-method. There should be an error code for lost connection.
2) If you don't use autocommit, it should be the database's job not to store any data that's not commited.
--
karl
|
|
|
|
|
hi thanks for paying attention to my query
i got solution for my problem
i just needed to use transation for updates
thanks again !
P.S. PATWAL
|
|
|
|
|
Hello
I have som problem i hope you could help me with
First of al:
My computer name JIMMY-217
I have installd Mysql on my local computer and done no changes to it(it is running)
I have installd the SQL Server Service Manager, and its running(but i dont know where the sql files i located or how to change them).
I have the MyODBC installd(working)
My problem is to get connected with MySQL servern in C#.
I have tryed on the foolowing ways
closed the SQL Server Service Manager and only have the MySql(WinMySQLAdmin) running
this is the connection code:
SqlConnection dataConnection = new SqlConnection();<br />
dataConnection.ConnectionString = "Integrated Security=true;Initial Catalog = mysql; Data Source=localhost"; <br />
<br />
dataConnection.Open();
But i get the Following error:
Cannot open database requested in login 'mysql'
mysql is a database that is i in the mysql server from start as example or somthing, if this is wrong how do i type to get the correct connection(adress)
I have tryed this turtorial(http://www.devarticles.com/art/1/250) and got it working with the Access file, but not with the SQL server.
If i start up the SQL Server Service Manager and make som changes for example
(Initial Catalog = Northwind), then it will connect to this server but it will say that it cant find the database, but this is not so inportant i think, the main thing is to get the connection to MySQL servern to work.
I hope you got som ides on this problem
I have on more problem, in the mysql(WinMySQLAdmin) -> databases i cant get teh creat and delete commands, i think it has somthing to do with the login, i have to login on root or somthing, but how do i login with a diffrent user? i have tryd to change the my.ini but this didnt help.
Best Regards
Jimmy
|
|
|
|
|
The SqlConnection from the System.Data.SqlClient is for connecting to a MS SQL Server. If you are trying connect to your MySql, try a OLEDB provider and use the OleDbConnection class.
Other way is by using the ODBC.NET library from MS.
I see dumb people
|
|
|
|
|
Thanks for the help
I Think this code is right but i need to connect it to MySql.
OleDbConnection Myconnection = null; <br />
OleDbDataReader dbReader = null; <br />
<br />
Myconnection = new OleDbConnection (@"Provider=Microsoft.Jet.OLEDB.4.0; User Id=; Password=; Data Source=C:\familyTree.mdb"); <br />
Myconnection.Open();
I dont know how to change this code so it will work with mysql(have look along time)
I know that i have to change the User Id and pass to one that can loggon to the SQL server, but what do i change the Data Source to? (my computer name is JIMMY-217, but i dont know how to get the right adress to connect)
Then the first((@"Provider=Microsoft.Jet.OLEDB.4.0;) i probely have to change to.
Hope you have an ide on this
Best regards
Jimmy
|
|
|
|
|
In addition to what has already been posted, you might want to try the tool at this link:
http://www.devhood.com/tools/tool_details.aspx?tool_id=655[^]
It seems to be a fully-managed provider for MySQL. I haven't tried it myself, but I did download the personal version (free). If you want to deploy it in a product or "real" application, it costs a little, but you get more features such as transactions, connection pooling, etc.
As was mentioned before, the SqlClient classes are designed specifically for MS SQL Server.
RabidK
|
|
|
|
|
But cant i use OLE DB to connect to MYSQL
if i can how will the connection line look like
//Jimmy
|
|
|
|
|
I don't think you can use the OLEDB connection for MySQL.
Use ODBC.NET, it works just fine.
Dave.
|
|
|
|
|
I have manage to connect to my local mysql database with this code
System.Data.OleDb.OleDbConnection con;<br />
con=new System.Data.OleDb.OleDbConnection("");<br />
con.ConnectionString="Provider=MySQLProv;Data Source=mysql;";<br />
<br />
<br />
try<br />
{<br />
con.Open();<br />
if (con.State==ConnectionState.Open) MessageBox.Show("Connection to MySQL opened through OLE DB Provider");<br />
con.Close();<br />
}<br />
catch(Exception ex)<br />
{<br />
MessageBox.Show(ex.Message);<br />
}
How do i do to delete, change, read etc in this database, and how do i send mySQL commands with this? Do i realy have to use ODBC.NET to this?
I have installed ODBC.NET but it simes like the C# dont find the namespace using Microsoft.Data.Odbc
|
|
|
|
|
Have a look at the OleDbDataReader and OleDbCommand classes. These allow you to execute SQL against the database.
If you want to use ODBC.NET, you need to add a reference to it in visual studio. If you've got it to connect with OleDB however, theres not much advantage in using ODBC.
Dave.
|
|
|
|
|
I am using MyOLEDB
Im realy comfused about al this diffrent connections(OLE DB, ODBC etc), maby you got a linkg about this?
|
|
|
|
|
Hello again, now i have get the code to work, it shows the stuf in the mysql server in to a form in C#.
{<br />
IDataReader reader;<br />
IDbCommand cmd;<br />
System.Data.OleDb.OleDbConnection con;<br />
con=new System.Data.OleDb.OleDbConnection("");<br />
con.ConnectionString="server=localhost;Provider=MySQLProv;Data Source=database;";<br />
<br />
try<br />
{<br />
con.Open();<br />
if (con.State==ConnectionState.Open)<br />
{<br />
cmd = con.CreateCommand();<br />
cmd.CommandText = "UPDATE humans SET Name = 'Nisse' WHERE id = '3'";<br />
cmd.ExecuteNonQuery();<br />
cmd.CommandText = "SELECT * FROM humans";<br />
reader = cmd.ExecuteReader();<br />
<br />
while (reader.Read())<br />
{<br />
lb.Items.Add(reader.GetString(1) + " " + reader.GetString(2));<br />
}<br />
MessageBox.Show("Connection to MySQL opened through OLE DB Provider");<br />
con.Close();<br />
}<br />
}<br />
catch(Exception ex)<br />
{<br />
MessageBox.Show(ex.Message);<br />
}<br />
}<br />
<br />
}
But as you se i am trying to update the mysql data base. This does not work i get the following error DB_ERRORSINCOMMAND(0x80040E14)
Do you got a ide of why i get this error?
|
|
|
|
|
Snowjim wrote:
cmd.CommandText = "UPDATE humans SET Name = 'Nisse' WHERE id = '3'";
Is it because you have quotes around the 3?
Should it read:
cmd.CommandText = "UPDATE humans SET Name = 'Nisse' WHERE id = 3";
Dave
|
|
|
|
|
MyOleDB will only connect to MySQL.
OLEDB and ODBC will connect to a variety of databases. ODBC probably will connect to more because it can use normal ODBC drivers which have been around for a longer time.
If your app only has to work with only one database, then it doesn't really matter which you use.
Each of them have practically the same API so there isn't much in it programming wise.
Dave.
|
|
|
|
|
Hi all
I wanna make a timestamp field in access, so I chose to use a DateTime field, but it appears .NET inserts only the date part of the value, no time part. So I decide to use a long integer instead (DateTime.ToFileTime()), but .NET (OleDBAdapter) sees this only as an int whether the field is a long integer or a normal integer.
WHat must I do?
CHeers
Who is this miscrosoft, and what devilish plans have they for us?
|
|
|
|
|
If you're inserting records, a simple way is to not insert a value, but let Access insert it for you. So create the datetime column, set it's default value to "Now()" in Access, and leave it out of your insert statement!
|
|
|
|
|
Bernhard Hofmann wrote:
set it's default value to "Now()" in Access, and leave it out of your insert statement!
Exactly what I ended up doing Thanks anyways.
Who is this miscrosoft, and what devilish plans have they for us?
|
|
|
|
|
Bernhard Hofmann wrote:
If you're inserting records, a simple way is to not insert a value, but let Access insert it for you. So create the datetime column, set it's default value to "Now()" in Access, and leave it out of your insert statement!
Thats all nice and well, but what about my SELECT statement now? Same problem...
Who is this miscrosoft, and what devilish plans have they for us?
|
|
|
|
|
Hi
From what I've read, you should be using the Date OleDbType (DBTYPE_DATE), which "maps" to a System.DateTime. The DBTYPE_DATE is a double, with
"The whole portion is the number of days since December 30, 1899, while the fractional portion is a fraction of a day." - MSDN Library
What programming language?
(BTW: Nice DUMeter)
|
|
|
|
|
Bernhard Hofmann wrote:
From what I've read, you should be using the Date OleDbType (DBTYPE_DATE), which "maps" to a System.DateTime. The DBTYPE_DATE is a double, with
This is my select cmd:
SELECT ID, Recv, Send FROM RateLog WHERE (ID > ?)
this.oleDbSelectCommand1.Parameters.Add(
new System.Data.OleDb.OleDbParameter("ID", System.Data.OleDb.OleDbType.DBDate, 0, "ID"));
where "ID" is the timestamp field.
Then I would pass DateTime.Now.AddHours(-3) for example.
All in C# in MyDUMeter.
MyDUMeter: a .NET DUMeter clone
|
|
|
|
|
I am trying to figure out how do to a bulk insert from C#.
Can any one help me?
Darryl Borden
Principal IT Analyst
darryl.borden@elpaso.com
|
|
|
|