connection string
gmorken
Member Posts: 38
Hello,
I´m writing an odbc connection in c#.net
I am able to connect to nav.database but I'm getting an exception on the connectin string. The string looks like this.
command.CommandText = "SELECT Artikeltransaktion.Artikelnr, SUM(Artikeltransaktion.Återstående Antal) "
+ "FROM Artikeltransaktion "
+ "WHERE (Artikeltransaktion.Lagerställekod='LID') AND (Artikeltransaktion.Öppen=1) "
+ "GROUP BY Artikeltransaktion.Artikelnr "
+ "ORDER BY Artikeltransaktion.Artikelnr";
The compiler doesnt like the blankspace in Återstående Antal.
How can I write this string instead?
Regards
I´m writing an odbc connection in c#.net
I am able to connect to nav.database but I'm getting an exception on the connectin string. The string looks like this.
command.CommandText = "SELECT Artikeltransaktion.Artikelnr, SUM(Artikeltransaktion.Återstående Antal) "
+ "FROM Artikeltransaktion "
+ "WHERE (Artikeltransaktion.Lagerställekod='LID') AND (Artikeltransaktion.Öppen=1) "
+ "GROUP BY Artikeltransaktion.Artikelnr "
+ "ORDER BY Artikeltransaktion.Artikelnr";
The compiler doesnt like the blankspace in Återstående Antal.
How can I write this string instead?
Regards
0
Comments
-
Are you using NODBC and is license open for ODBC?
If using NODBC:
Swedish chars has to be typed with ASCII (DOS) not ANSI (windows)
SELECT Fakturahuvud.Nr, Fakturahuvud."Bokf”ringsdatum", Fakturahuvud."F”rfallodatum"
FROM Fakturahuvud Fakturahuvud
Create the query in MSQuery from Excel, it helps you with the syntaxRegards
Dan Lindström
NCSD Navision 2.00 since 1999 (Navision Certified Solution Developer)
MBSP Developer for Microsoft Dynamics NAV 20090 -
its not complaining about the swedish chars. its the blankspaces that is the problem.
My code looks like this.
private void button1_Click_1(object sender, EventArgs e)
{
OdbcConnection myConn = new OdbcConnection(myConnection);
myConn.Open();
OdbcCommand command = myConn.CreateCommand();
string temp = "Återstående antal";
command.CommandText = "SELECT Artikeltransaktion.Artikelnr, SUM(Artikeltransaktion.Återstående Antal) " // HERES THE PROBLEM
+ "FROM Artikeltransaktion "
+ "WHERE (Artikeltransaktion.Lagerställekod='LID') AND (Artikeltransaktion.Öppen=1) "
+ "GROUP BY Artikeltransaktion.Artikelnr "
+ "ORDER BY Artikeltransaktion.Artikelnr";
label3.Text = command.CommandText;
OdbcDataReader rdr = command.ExecuteReader();
while (rdr.Read())
{
listBox1.Items.Add(rdr.GetString(0));
listBox1.Items.Add(rdr.GetString(1));
}
int i = listBox1.Items.Count;
label5.Text = i.ToString();
myConn.Close();
}
The problem is
Artikeltranskaktion.Återstående antal
This works
Artikeltransaktion.Antal
I suppose its the blankspaces.0 -
Try to enclose these field names to brackets like []0
-
do you mean like
Artikeltransaktion.[Återstående antal]
?0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 611 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
