473,569 Members | 2,762 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

string syntax

Hi I'm attempting to pass a string into another string but I get an error

This code work ok

jro.CompactData base(@"Provider =Microsoft.Jet. OLEDB.4.0;Data
Source=C:\Compa ct.mdb", @"Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=C:\tempd b.mdb;Jet OLEDB:Engine Type=5");

However when I declare a string and try to pass that I get an error

string mdbTemp = @"C:\tempdb.mdb ";

jro.CompactData base(@"Provider =Microsoft.Jet. OLEDB.4.0;Data
Source=C:\Compa ct.mdb", @"Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=mdbTemp; Jet OLEDB:Engine Type=5");
Nov 16 '05 #1
2 1911
use the following:

jro.CompactData base
(
@"Provider=Micr osoft.Jet.OLEDB .4.0;Data Source=C:\Compa ct.mdb",
@"Provider=Micr osoft.Jet.OLEDB .4.0;Data Source=" + mdbTemp + @";Jet
OLEDB:Engine Type=5"
);

"jez123456" <je*******@disc ussions.microso ft.com> schrieb im Newsbeitrag
news:75******** *************** ***********@mic rosoft.com...
Hi I'm attempting to pass a string into another string but I get an error

This code work ok

jro.CompactData base(@"Provider =Microsoft.Jet. OLEDB.4.0;Data
Source=C:\Compa ct.mdb", @"Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=C:\tempd b.mdb;Jet OLEDB:Engine Type=5");

However when I declare a string and try to pass that I get an error

string mdbTemp = @"C:\tempdb.mdb ";

jro.CompactData base(@"Provider =Microsoft.Jet. OLEDB.4.0;Data
Source=C:\Compa ct.mdb", @"Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=mdbTemp; Jet OLEDB:Engine Type=5");

Nov 16 '05 #2


"jez123456" wrote:
Hi I'm attempting to pass a string into another string but I get an error

This code work ok

jro.CompactData base(@"Provider =Microsoft.Jet. OLEDB.4.0;Data
Source=C:\Compa ct.mdb", @"Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=C:\tempd b.mdb;Jet OLEDB:Engine Type=5");

However when I declare a string and try to pass that I get an error

string mdbTemp = @"C:\tempdb.mdb ";

jro.CompactData base(@"Provider =Microsoft.Jet. OLEDB.4.0;Data
Source=C:\Compa ct.mdb", @"Provider=Micr osoft.Jet.OLEDB .4.0;Data
Source=mdbTemp; Jet OLEDB:Engine Type=5");


Hi jez123456,

You can never pass a string in another string. One have to concat two string
or format a string!

1) Concatenation

string mdbTemp = @"C:\tempdb.mdb ";

string target = @"Provider=Micr osoft.Jet.OLEDB .4.0;DataSource =" + mdbTemp +
@";Jet OLEDB:Engine Type=5"

OR

string target =
string.Concat(@ "Provider=Micro soft.Jet.OLEDB. 4.0;DataSource= ", mdbTemp,
@";Jet OLEDB:Engine Type=5"
jro.CompactData base(@"Provider =Microsoft.Jet. OLEDB.4.0;Data
Source=C:\Compa ct.mdb", target);

2) Formatting

string mdbTemp = @"C:\tempdb.mdb ";

string target =
string.Format(@ "Provider=Micro soft.Jet.OLEDB. 4.0;DataSource= {0};Jet
OLEDB:Engine Type=5", mdbTemp);

jro.CompactData base(@"Provider =Microsoft.Jet. OLEDB.4.0;Data
Source=C:\Compa ct.mdb", target);
Roland
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
4349
by: al | last post by:
char s = "This string literal"; or char *s= "This string literal"; Both define a string literal. Both suppose to be read-only and not to be modified according to Standard. And both have type of "const char *". Right? But why does the compiler I am using allow s to be modified, instead of generating compile error?
8
13939
by: Jeff Johnson | last post by:
Hi, I've begun converting an ASP site over to .NET and I'm a novice at both the new platform as well as C#. I have a COM+ object that returns a string array when it is called. The size of the array can vary depending on the parameters passed. What I need to do is loop through the returned array and if applicable write the array...
1
7462
by: Minh | last post by:
I've just installed VS.NET 2003 on my Athlon XP 1800+. However I couldn't get any project with STL includes to compile even if I create a new empty project (and added #include <string>). It gave me a bunch of "missing ;" errors. I did reinstall the whole thing a few times but it didn't work. Anyone have any idea? Thanks c:\Program...
7
1490
by: Ioannis Vranos | last post by:
I had reported this as a bug: Description: Default indexed property of System::String crashes for object with stack semantics. int main()
3
3977
by: Rich | last post by:
Hello, I am converting an app from VB6 to VB.Net and have encountered the following problem. I have the following loop which retrieves objects from a collection of objects. Dim entry As Domino.NotesViewEntry Dim obj As Object, str1 As String .... For Each obj In entry.ColumnValues.ToString
2
2942
by: Diana | last post by:
I thought I had this process pretty well down pat, but I'm getting a syntax error on the following code: *****Code***** 'Check for users - can't get this to work... Dim strUser As String strUser = WUserName() If IsNull(DLookup("Permitted", "tblUsers", "Permitted = '" &
31
3107
by: Peter Michaux | last post by:
Hi, I want to know the name of an object's constructor function as a string. Something like this <script type="text/javascript"> function Foo(){}; var a = new Foo(); alert('"' + a.constructor.toString().match(/function\s*(+)/)
2
1895
by: Shashank | last post by:
Hi, I am passing a tcpdump filter to a function which compiles the filter using pcap_compile and then sets it. Here is the filter, ip>=0x0000 and ip <=0xd9295a3 and ip >=0x0000 and ip <=0x3ca9b416 and tcp>=0 and tcp<=23923 and tcp>=0 and tcp<=64582 and tcp<=655355 I have many threads passing different filters of a similar form to
6
1789
by: Bill Cunningham | last post by:
As I have been studing my tutorial I came up with this question. I took char passw(char name); and initialied this function in a header with other includes for standard library headers. This doesn't seem to work so is what I want this? char passw(char *name); I haven't got to pointers in the tutorial and I'm taking my time. But in this...
16
2148
by: Anil Gupte/iCinema.com | last post by:
Can someone please explan the difference between Dim temp as String() and Dim temp() as String in terms of syntax and practical usage? I thought I knew, but of late have become confused due to reasons too complicated to go in here.
0
7609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7921
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6278
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2107
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.