|
I want to run stored procedure with some paraneters from my asp.net application.I use this code but I got run=time error at the last line:
SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlParameter[] parameters =
{
new SqlParameter("@Table", SqlDbType.NVarChar , 50),
new SqlParameter("@ID" , SqlDbType.BigInt , 8)
};
parameters[0].Value = Page.Request.Params["Cat"];
parameters[1].Value = int.Parse(Page.Request.Params["id"]);
SqlCommand command = new SqlCommand();
foreach (SqlParameter parameter in parameters)
{
command.Parameters.Add( parameter );
}
command.Connection = conn;
command.CommandType = System.Data.CommandType.StoredProcedure;
command.CommandText = "sp_Votes_GetVotes";
if(conn.State == System.Data.ConnectionState.Closed)
conn.Open();
SqlDataReader dr = command.ExecuteReader();
The error is:
Error converting data type nvarchar to bigint.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
Hiya getting a message saying "Database error - There were no columns specified to retrive." when using these 2 lines:
SqlString = "DELETE * from Branches WHERE Branch_No LIKE '4%' ";
OR
SqlString = "INSERT INTO Branches (Branch_No,Branch_Name) VALUES ('6','Derry') ";
But Branch_No is the first column and Branch_Name is the second..
Am I using the statements wrong??
Thanks,
grahamoj.
|
|
|
|
|
DELETE statement do not need * from.Change it to:
DELETE Branches WHERE Branch_No LIKE '4%'
For second one,Whats the type of columns?
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
You don't need the "*" but you'll need "from" so the right statement will be (at least in SQL92)
DELETE FROM branches WHERE branch_no LIKE '4%'
--
karl
|
|
|
|
|
Yes.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
Would you have a full list of all the statements( that is right syntax ) available to use for me??
What is the syntax for the INSERT??
Thanks for ur help.
grahamoj.
|
|
|
|
|
Hiya have tried the DELETE as u suggested but still not working for me.
I think I know what it is though. What should this line change to for reading and writing..
// Execute the query
recset.Open( CRecordset::forwardOnly,SqlString,CRecordset::readOnly );
Have tried a "CRecordset::writeOnly, but none exists.
Thanks
grahamoj.
Have also tried this:
recset.Open( AFX_DB_USE_DEFAULT_TYPE,SqlString,CRecordset::none );
|
|
|
|
|
|
Does anyone know how to get the name of the database server I am connecting to with OleDB.NET in C# e.g. is it SQL Server or is it Oracle, etc.
Cheers,
Dave.
|
|
|
|
|
Usually most of that information can be obtained from your OleDbConnection object. Look up the public properties of that class.
Bruce Duncan, CP#9088, CPUA 0xA1EE, Sonork 100.10030 I can levitate birds...
|
|
|
|
|
I've looked at them and that info doesn't seem to be available. Any other ideas?
Ta,
Dave.
|
|
|
|
|
Hey All -
I'm wondering if anyone else has come across a similar problem and/or solution.
I've implemented a desktop application in .NET (C#). In order to increase performance, it maintains a local cache of server-side data in a collection of DataTable objects (since I'm not retrieving this data from a DB, I'm not using the DataAdapter, I'm building these DataTable objects dynamically).
Anyway, in order to optimize the application, I'm refactoring the application to use several threads for different things. Now, the problem this introduces is I no have the possibility of two threads attempting a write operation to the same DataTable object (which, according to the MSDN does not support thread safe write operations -- BOO! )
Rather than write set() methods for all my dataTable objects and look after the write synchronization, I'm wondering if its possible to just create two new objects, perhaps SynchroDataTable and SynchroDataRow that extend DataTable and DataRow respectively and synchronize the appropriate properties. That way, I can multithread my app without writing to much new data access/update code.
Has anyone tried something similar? What were your experiences, strategies?
Any/all comments, suggestions, code, solutions, URLs, etc.. are appreciated!
Regards,
Bill
--
Bill D. Baldasti
Canuck Coder in T-dot!
|
|
|
|
|
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.
|
|
|
|