473,396 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

string syntax

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

This code work ok

jro.CompactDatabase(@"Provider=Microsoft.Jet.OLEDB .4.0;Data
Source=C:\Compact.mdb", @"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\tempdb.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.CompactDatabase(@"Provider=Microsoft.Jet.OLEDB .4.0;Data
Source=C:\Compact.mdb", @"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=mdbTemp;Jet OLEDB:Engine Type=5");
Nov 16 '05 #1
2 1895
use the following:

jro.CompactDatabase
(
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Compact.mdb",
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + mdbTemp + @";Jet
OLEDB:Engine Type=5"
);

"jez123456" <je*******@discussions.microsoft.com> schrieb im Newsbeitrag
news:75**********************************@microsof t.com...
Hi I'm attempting to pass a string into another string but I get an error

This code work ok

jro.CompactDatabase(@"Provider=Microsoft.Jet.OLEDB .4.0;Data
Source=C:\Compact.mdb", @"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\tempdb.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.CompactDatabase(@"Provider=Microsoft.Jet.OLEDB .4.0;Data
Source=C:\Compact.mdb", @"Provider=Microsoft.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.CompactDatabase(@"Provider=Microsoft.Jet.OLEDB .4.0;Data
Source=C:\Compact.mdb", @"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\tempdb.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.CompactDatabase(@"Provider=Microsoft.Jet.OLEDB .4.0;Data
Source=C:\Compact.mdb", @"Provider=Microsoft.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=Microsoft.Jet.OLEDB.4.0;DataSource=" + mdbTemp +
@";Jet OLEDB:Engine Type=5"

OR

string target =
string.Concat(@"Provider=Microsoft.Jet.OLEDB.4.0;D ataSource=", mdbTemp,
@";Jet OLEDB:Engine Type=5"
jro.CompactDatabase(@"Provider=Microsoft.Jet.OLEDB .4.0;Data
Source=C:\Compact.mdb", target);

2) Formatting

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

string target =
string.Format(@"Provider=Microsoft.Jet.OLEDB.4.0;D ataSource={0};Jet
OLEDB:Engine Type=5", mdbTemp);

jro.CompactDatabase(@"Provider=Microsoft.Jet.OLEDB .4.0;Data
Source=C:\Compact.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
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...
8
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...
1
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...
7
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
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...
2
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 ...
31
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('"' +...
2
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...
6
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...
16
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.