|
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
|
|
|
|
|
What about doing a bcp by calling a SQL script/T-SQL statement as per usual?
Would that be OK?
Cheers,
Simon
"The day I swan around in expensive suits is the day I hope someone puts a bullet in my head.", Chris Carter.
animation mechanics in SVG
|
|
|
|
|
The problem with that is that the project manager wants error checking and doesn't want the program hosed because there was a problem with bcp.
Apparently, in C++, there is a way to open the database connection for what is called a fast insert. I can't find any documentation on this but was hoping someone has done this kind of thing in c#.
dpb
Darryl Borden
Principal IT Analyst
darryl.borden@elpaso.com
|
|
|
|
|
Look up the IRowsetFastLoad interface.
I used it it C++ a while back, not sure if you can get to it from C#, or if there is a similar/simpler way of doing this in .NET.
Unfortunately, I lost my code, so I cannot be much more help than this.
Bruce Duncan, CP#9088, CPUA 0xA1EE, Sonork 100.10030 I can levitate birds...
|
|
|
|
|
Hi, i´m new to ADO.NET and i have a couple of questions.
Is there any way to automatically make an insertion using windows forms?
I can make the user enter the data and add a row to the data set, or add a row using the method on the dataview. But in this way i have to keep all the UI logic by myself, because the controls don´t update their content.
Gabriel
Old C programmers never die. They just cast into void
|
|
|
|
|
We have a project which started as a "pure" Access application. Access front end and Access back end.
However the app got popular and the Access BE could not handle it all. So the FE stayed the same but the BE was converted to SQL.
There are still problems though. Namely even in a development environment with a fresh machine and nobody else accessing the application, record locks occur.
Does anyone know anything about doing this kind of conversion and whether it is a good idea to have an Acess FE and SQL BE? Here is some of the apps code, the recordset opening bit, is it correct?:
Set db = CurrentDb
Set rsConcession = db.OpenRecordset(strSQL, dbOpenDynaset, dbSeeChanges)
With rsConcession
.Edit
!LinkNo = LinkNo
!Date = Now
!SpecNo = intSpecNo
!BrandNo = intSpecNo
!ParameterNo = intParameterNo
!ProcessNo = intProcessNo
!Code = Code
!ConcessionType = ConcessionType
!OOS = OOS
!OOC = OOC
!OOB = OOB
!Value = Value
If Len(CommentInput) > 0 Then !Reason = CommentInput
!ConcessionCode = ConcessionCode
!OriginatorNo = Forms!Logon!UserNo
!AnalysisNo = intAnalysisNo
.Update
.Close
I have no experience in Access or Access code to use a SQL db. Any help appreciated, ta.
Paul Watson Bluegrass Cape Town, South Africa
Roger Wright wrote:
Using a feather is kinky; using the whole chicken is perverted!
|
|
|
|
|
Yuk! I haven't done any development in Access for years, and you've just reminded me why!
Wouldn't it be easier to build a SQL UPDATE statement, and use the Execute method of the Database object to pass it through to the server?
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Richard Deeming wrote:
Wouldn't it be easier to build a SQL UPDATE statement, and use the Execute method of the Database object to pass it through to the server?
Thanks for the suggestion. That was basically our recommendation too. Seems as though the clients developer was using ODBC and coupled with those horrid DynaSet things was locking the row on just a simple view. Then when he wanted to update, the low was still locked and it refused.
Access front end to SQL back end is scary IMO, not a good idea.
Paul Watson Bluegrass Cape Town, South Africa
Roger Wright wrote:
Using a feather is kinky; using the whole chicken is perverted!
|
|
|
|
|
After doing some reading, I'm not exactly sure how to do this. Basically, I have a login screen with username and password textboxes. The user enters their information, then clicks Login. In the login button's click event I want to search an Access database table to see if the user is found, and if so, proceed to the main screen.
Could someone point me in the right direction, or post a link to a code sample? It would be greatly appreciated!
|
|
|
|