|
|
If you are using .NET 2, take a look at the DB Provider classes that were introduced. These classes, such as DbCommand[^] are intended to provide you with a relatively database agnostic way of working with your data. You can get more detailed information here[^].
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi
Try using the following code
that use generics in order to construct the desired type sqlcommand
class Program
{
public static T SetupCommand<T>() where T : IDbCommand, new()
{
T cmd = new T();
cmd.CommandText = "SELECT * FROM Test";
cmd.CommandTimeout = 180;
return cmd;
}
static void Main(string[] args)
{
SqlCommand sqlClientCmd = SetupCommand<SqlCommand>();
OleDbCommand oleDBCmd = SetupCommand<OleDbCommand>();
}
}
-- modified at 6:21 Friday 5th October, 2007
|
|
|
|
|
Hello. I want to post to a blog using C#, any have an idea of how to do that?
Thanks a lot !!!
|
|
|
|
|
That's insufficient information to give you a meaningful answer. What blog hosting service are you trying to post a blog to? Services like Blogger, for example, give a public API you can call via web services.
I recommend you figure out which blog hosting service to publish a blog post to, then go to that service's developer API site and figure out how to call their web service APIs via .NET.
|
|
|
|
|
Do you mean that you want to write a blogging engine in C#? If so, have a search on this site for Marc Clifton's articles on creating a simple blogging engine.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I want to create a menubar or content box that sides up out of the way at the click of a button. It doesn't have to be a menu, per se, I can just place images and/or buttons in a sliding area. I just want to be able to click and have it slide up, or down, giving me access to the buttons when I need them.
|
|
|
|
|
hi there,
i put all the data in byte[], now i wanna read it like binary reader
is there any way?
Becoming Programmer...
|
|
|
|
|
Yeah,
Initialise a MemoryStream from the array, and then use the BinaryReader on that.
Regards,
Rob Philpott.
|
|
|
|
|
thanks but my problem solved
Becoming Programmer...
|
|
|
|
|
If you already have an array of bytes, then... what's the problem?? For example you can iterate these bytes using the for statement.
for (int i = 0; i < arr.Length; i++) {
byte myByte = arr[i];
}
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
Hi,
I need to manage a treeview control with a vertical scrollbar control. I can't use the default scrollbar of the treeview and so I have to disable scrollbars on the treeview and use an external vertical scrollbar. Is this possible?
|
|
|
|
|
Hi guys
How can I delete all occurrences of the word 'test' from a string
I.e. String Before: This is a test to delete all occurrences of the word test
String After: This is a to delete all occurrences of the word
Please give me some guidelines here.
Thanks
R
|
|
|
|
|
You can use split, like this:
string myString = "this is a test waffle";
string temp[] = myString.Split("test ");
myString = "";
foreach(string str in temp) {
myString += str;
}
Then, after all that, your string should be "this is a waffle".
|
|
|
|
|
what you could do is keep it simple
use string.Replace.
ex:
string x = "This is a test,test";
string y = x.Replace("test","");
Console.WriteLine(y);
output should look like "This is a , "
have fun
Kaine
|
|
|
|
|
Damn, string.Replace. How could i forget that. Oh well, time to go methinks.
On a side note, i appear to have found a new forum to live on for a while. Who would have thought it'd be here?
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
Thanks to both of you that replied!!
R
|
|
|
|
|
But what if you were to remove a word like '{test}' including the braces?
|
|
|
|
|
Nevermind I got it now, I'm just being stupid today...
Thanks again guys!
|
|
|
|
|
Is there a neater more professional way to re-write the code below?
<br />
public string StripString(string statementString)<br />
{<br />
string alteredStatement = string.Empty;<br />
<br />
string keyword1 = "[dbo].";<br />
string keyword2 = "[";<br />
string keyword3 = "]";<br />
string remover = "";<br />
<br />
string tmpStr1 = statementString.Replace(keyword1, remover);<br />
string tmpStr2 = tmpStr1.Replace(keyword2, remover);<br />
<br />
alteredStatement = tmpStr2.Replace(keyword3, remover);<br />
<br />
return alteredStatement;<br />
}<br />
|
|
|
|
|
Do you mean something like this?
Regex.Replace(statementString, @"\[|dbo].|\]", "");
instead of the function
Greetings
Kaine
|
|
|
|
|
I was thinking of Regex but wasn't sure.
Thanks for that Kain!
|
|
|
|
|
I'm not sure why you're removing the brackets and 'dbo' from SQL. It could open you up to syntax errors, especially since you don't account for the context whatsoever in these sort of find/replace methods. Plus, I remember reading somewhere that stating 'dbo' will improve lookup performance
But whatever...just throwing that out there as a word of caution.
|
|
|
|
|
This one is more concise and more efficient since it doesn't create unnecessary temporary string instances.
public string StripString(string statementString)
{
string[] keywords = { "[dbo].", "[", "]" };
StringBuilder result = new StringBuilder(statementString);
foreach (string keyword in keywords) result.Replace(keyword, string.Empty);
return result.ToString();
} Now, let me ask you a question. It appears you're trying to parse a connection string - is that what you're trying to do? Are you aware there's already a class in the .NET framework that parses a connection string and give you back the interesting pieces of information? That would be OdbcConnection; pass a connection string in the constructor and you'll have a connection object containing all the properties of the connection string.
|
|
|
|
|
string s = "this is a test";
s.Replace("test", "");
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|