|
Hiya I have only started to learn SQL in MFC/C++. I have a program that opens a ACCESS DATABASE and I can do queries on it no problem using SQL. My question is how is a SQL server accessed??
Is it the same as I have accessed the ACCESS DATABASE?? Normally on a SQL server, are the files all kept as databases and that is how you can access them the same??
Can anyone give me some info on accessing a database on a SQL server..
Thank you.
grahamoj.
|
|
|
|
|
|
How do I go about inserting a string that contains a ' into a table when it is considered the end of my string? I'm using VB - shhhhh! - and I've tried escaping it with a \ but that doesn't seem to help.
[edit]
I'm currently using ADO and trying to use Connection.Execute and a full SQL INSERT statement. Would it be easier to use Recordset.AddNew and then just manually set the fields?
[/edit]
Is it possible?
J
"We cross our bridges when we come to them and burn them behind us, with nothing to show for our progress except a memory of the smell of smoke, and a presumption that once our eyes watered." - Tom Stoppard - Rosencrantz and Guildenstern are Dead.
|
|
|
|
|
Replace("Some string with a ' in it", "'", "''") should do the trick.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Richard Deeming wrote:
should do the trick.
No kidding? What's the logic there? I thought two single quotes together mean string concatenation...
I'll give it a try when I get home. Thanks!
J
"We cross our bridges when we come to them and burn them behind us, with nothing to show for our progress except a memory of the smell of smoke, and a presumption that once our eyes watered." - Tom Stoppard - Rosencrantz and Guildenstern are Dead.
|
|
|
|
|
(FYI: The app in question will be an ASP.NET web application interfacing a Sybase back-end.)
I'm new to the web arena and I am trying to get a feel for which one I should choose. Please share any thoughts or experiences
Which is better... ADO.NET or ODBC.NET?
Why would someone choose one over the other?
What benefits do you get with ADO.NET?
What benefits do you get with ODBC.NET?
Any drawbacks to either one?
Thanks!
ExtraLean
--
Edward Livingston
aka. ExtraLean
--
|
|
|
|
|
ODBC.NET is a database/driver specific part of ADO.NET. Others are SqlClient for Sql Server, and OleDb for databases that have OleDb drivers available.
Preferrably you'd want to use a provider (in your case Sybase) that is specifically tailored for .NET (like the SQL one is specific for MS Sql Server)
If no such .NET specific driver is available your next best bet is an OLEDB driver and the OleDb .NET classes.
If you're still out of luck (no db specific .NET or OLEDB support), ODBC.NET is your only option. I have used ODBC.NET to access ODBC data sources with out any trouble.
To summarize (I hope), you aren't choosing between ADO.NET or ODBC.NET, but rather ODBC.NET, OleDB, or a Sybase specific .NET implementation. The best option being the last one.
Why? ODBC is older technology, and you may not be able to make full use of the available ADO.NET functionality.
Hope this helps, ( and that I didn't babble on too long )
Bruce Duncan, CP#9088, CPUA 0xA1EE, Sonork 100.10030 I can levitate birds...
|
|
|
|
|
Please excuse me for butting in but I have a question.
You stated:
"ODBC.NET is a database/driver specific part of ADO.NET. Others are SqlClient for Sql Server, and OleDb for databases that have OleDb drivers available."
Does this mean that OleDb uses COM to tonnect to the database?
Does this also mean that if you don't want to use SQL Server then then the only way is to use COM?
The reason I am asking is because I am writing an application in which I wish to use an Access database. However, if the database doesn't exist, I want to programatically re-create the database.
I have done this in the past using VB6 but as I am now using .Net have been investigating ADO.Net. The problem is that all the examples/resources I have found only demonstrate database creation using the SQL Server which I don't want to use.
|
|
|
|
|
BusterG wrote:
Does this mean that OleDb uses COM to tonnect to the database?
OleDb is COM based, if that is what you're asking. The are OleDb .NET class available, but they all ultimately talk to an underlying non .NET database driver.
BusterG wrote:
Does this also mean that if you don't want to use SQL Server then then the only way is to use COM?
No, there may be native .NET classes available for whatever data source you are using.
BusterG wrote:
I wish to use an Access database. However, if the database doesn't exist, I want to programatically re-create the database.
Firstly, I don't have any experience when it comes to coding against an Access database, so I may be talking a load of rubbish.
If I were required to use an Access db, I would first check if a .NET specific addon/driver was available and that it is stable/supported. Failing that, I would use the OleDb classes in the .NET framework (System.Data.OleDb.*) to interface with the Jet database driver.
I'm not sure how one would go about creating an Access db programmatically though.
A quick google search indicates that there is no native .NET method of doing this. So you will have to use ADOX or some other method to create an empty database.
Google Link[^]
Bruce Duncan, CP#9088, CPUA 0xA1EE, Sonork 100.10030 Blackadder: Baldrick, do you know what irony is? Baldrick: Yeah, it's like goldy and bronzy only it's made of iron.
|
|
|
|
|
I don't know about Sybase, but with Oracle I've found that ODBC.NET works better than OleDb. The OleDb class doesn't support all the different field types available whereas ODBC.NET seems to.
Dave
|
|
|
|
|
Hi,
Is there a way to list all DB2 Servers on the network just like we do with SQLDMO for SQL Servers in C#.
Thanks and Regards,
Deepak Kumar Vasudevan
http://deepak.portland.co.uk/
|
|
|
|
|
I have Access 2000 database with number of forms. How can I make one of them default, which is loaded when database is opened?
|
|
|
|
|
Do you want to set this via the Microsoft Access application or through ADO/etc? I don't know about the latter approach (I've looked at all the "MSys" tables but can't see anything to suggest it, and the docs are useless as ever), but on the off chance it's the former look under "Tools | Startup..." in the main application menu.
|
|
|
|
|
Thank you, this is exactly what I need.
|
|
|
|
|
Hiya does anyone have any tutorials or links on using C++ with SQL. I know C++ already but want to learn SQL. I will be using Visual C++ 6.0.
All I know is there is a header file called sql.h.
Thanks for any help..
grahamoj.
|
|
|
|
|
|
karl_w wrote:
http://www.w3schools.com
I'll recommend that one too - W3Schools looks like a great site for learning and quick reference alike, and not just for SQL. It is now added to my bookmarks.
I just took each of their quick tests and got...
HTML: 20/20
XHTML 17/20
CSS: 19/20
XML: 19/20
JavaScript: 20/20
ASP: 20/20
SQL: 20/20
...so I guess I'll be spending my afternoon reading through the XHTML and XML sections. (I only got the CSS question wrong because I missread the question. Honest. *cough* )
|
|
|
|
|
I am trying to get optimistic concurrency to work updating the employees table onf the northwind database to which I have added a datetime column to act as a timestamp. I am having trouble setting the timestamp column in the dataset after updating the dataAdapter. The update command stored procedure works, but because I cannot update the dataViewstate.Original of the timestamp column I cannot perform another update to the same column without refilling the dataset. I know the "timeStamp" parameter is being set by the stored proceudre because I can retrieve the new timestamp value from the parameter in the datasets _RowUpdated event. It seems like the update to the columns should happen automatically base on what info I can find. AmWhat am I missing. Help. I have included the updateCommand and _RowUpdated code below.
Thanks,
Burke
// oleDbUpdateCommand1
//
this.oleDbUpdateCommand1.CommandText = "[up_Employees_Update]";
this.oleDbUpdateCommand1.CommandType = System.Data.CommandType.StoredProcedure;
this.oleDbUpdateCommand1.Connection = this.oleDbConnection1;
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("RETURN_VALUE", System.Data.OleDb.OleDbType.Integer, 4, System.Data.ParameterDirection.ReturnValue, false, ((System.Byte)(10)), ((System.Byte)(0)), "", System.Data.DataRowVersion.Current, null));
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("employeeID", System.Data.OleDb.OleDbType.Integer, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(10)), ((System.Byte)(0)), "EmployeeID", System.Data.DataRowVersion.Current, null));
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("firstName", System.Data.OleDb.OleDbType.VarWChar, 10, "FirstName"));
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("lastName", System.Data.OleDb.OleDbType.VarWChar, 20, "LastName"));
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("title", System.Data.OleDb.OleDbType.VarWChar, 30, "Title"));
this.oleDbUpdateCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("timeStamp", System.Data.OleDb.OleDbType.DBTimeStamp, 8, System.Data.ParameterDirection.InputOutput, false, ((System.Byte)(0)), ((System.Byte)(0)), "TimeStamp_ST", System.Data.DataRowVersion.Original, null));
private void oleDbDataAdapter1_RowUpdated(object sender, System.Data.OleDb.OleDbRowUpdatedEventArgs e)
{
int rowsUpdated = (int)oleDbDataAdapter1.UpdateCommand.Parameters["RETURN_VALUE"].Value;
string employeeName = oleDbDataAdapter1.UpdateCommand.Parameters["FirstName"].Value + " " + oleDbDataAdapter1.UpdateCommand.Parameters["LastName"].Value;
if (rowsUpdated != 1)
{
e.Command.Cancel();
addToListBox("Attepmt to update employee:" + employeeName + " returned " + rowsUpdated.ToString());
}
else
{
addToListBox("RowUpdated returned:" + oleDbDataAdapter1.UpdateCommand.Parameters["RETURN_VALUE"].Value.ToString() + " TimeStamp was :" + oleDbDataAdapter1.UpdateCommand.Parameters["TimeStamp"].Value.ToString());
}
DateTime dt = (DateTime)oleDbDataAdapter1.UpdateCommand.Parameters["TimeStamp"].Value;
addToListBox("New timestamp for " + employeeName + " = " + dt.ToString());
e.Row["TimeStamp_ST"] = dt.ToString();
e.Row.AcceptChanges();
// for (int i=0;i<=e.Row.Table.Columns.Count; i++)
// {
// addToListBox(e.Row.Table.Columns[i].ColumnName.ToString());
//
// }
//e.Row["TimeStamp"] = (DateTime)oleDbDataAdapter1.UpdateCommand.Parameters["NewTimeStamp"].Value;
//object str = (object)e.Row["NewTimeStamp",DataRowVersion.Original];
//addToListBox("TimeStamp str=" + str.ToString());
//DataRow cr = e.Row["TimeStamp",DataRowVersion.Original];
//cr["TimeStamp",DataRowVersion.Original] = (DateTime)oleDbDataAdapter1.UpdateCommand.Parameters["NewTimeStamp"].Value;
}
|
|
|
|
|
Hi everybody
I am using SQL Server 2000. The size of my actual data is 110MB. On the other hand the size of the respective transaction log is 7GB. Is the logical? If not is there a way to reduce it? Note that I use SQL Server's 2000 shrink menu option but the size will not reduce. IMHO this is tooooo much!!!!
Thank you in advance for your help
Spiros Prantalos
Miami the place to be!!
|
|
|
|
|
Go to the properties of your database, on the "Options" tab, choose "simple" recovery model, and make sure autoshrink is set.
|
|
|
|
|
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
|
|
|
|
|