15,898,538 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by JohnUSA (Top 34 by date)
JohnUSA
7-Dec-10 18:45pm
View
Deleted
thanks, just figure it! great help! :)
JohnUSA
7-Dec-10 18:19pm
View
Deleted
Hello again,
string conn1 = "SERVER=test;" + "DATABASE=books;" + "UID=db;" + "PASSWORD=abc;";
MySqlConnection conn = null;
MySqlCommand comm = null;
MySqlDataReader reader = null;
List<string> priceList = new List<string>();
string sql = "SELECT * FROM Books";
try
{
conn = new MySqlConnection(ConfigurationManager.ConnectionStrings[conn1].ConnectionString);
conn.Open();
comm = new MySqlCommand(sql, conn);
reader = comm.ExecuteReader();
while (reader.Read())
{
priceList.Add(reader["Price"].ToString());
}
}
finally
{
if (reader != null)
{
reader.Close();
}
if (conn != null)
{
conn.Dispose();
}
}
foreach (string s in priceList)
{
Console.WriteLine(s);
}
I am missing something? i get an error on:
conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString);
which is: Object reference not set to an instance of an object.
JohnUSA
7-Dec-10 17:16pm
View
Deleted
Hello,
i have done:
List<int> priceResults = new List<int>();
string conn = "SERVER=test;" + "DATABASE=books;" + "UID=db;" + "PASSWORD=abc;";
MySqlConnection conne= new MySqlConnection(conn);
MySqlCommand command = connection.CreateCommand();
MySqlDataReader Reader;
try
{
conne.Open();
command.CommandText = "SELECT Price FROM BooksTB WHERE Author ='" + author + "' AND ISBN ='" + ISBN + "'";
Reader = command.ExecuteReader();
while (Reader.Read())
{
priceResults.Add(mySqlReader["Price"].ToString());
}
conne.Close();
}
catch (Exception e)
{
Console.WriteLine("{0} Exception caught.", e);
}
but i can't save each one in differnet string! can you help me pls?
JohnUSA
4-Dec-10 18:29pm
View
How this will help ?
JohnUSA
4-Dec-10 18:22pm
View
Exactly the same error again!!!
You have no idea what else to try ?
JohnUSA
4-Dec-10 18:11pm
View
Yes, my string is String sql = "SELECT * \nFROM \n[BooksTable] \nWHERE \n[author] = '" + author + "' \nAND \n[ISBN] = '" + ISBN + "'";
MySql.Data.MySqlClient.MySqlException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[BooksTable]
WHERE
[author] = 'George Elliot'
AND
[ISBN ] = '1234'' at line 3
at MySql.Data.MySqlClient.PacketReader.CheckForError()
at MySql.Data.MySqlClient.PacketReader.ReadHeader()
at MySql.Data.MySqlClient.PacketReader.OpenPacket()
at MySql.Data.MySqlClient.NativeDriver.ReadResult(Int64& affectedRows, Int64& lastInsertId)
at MySql.Data.MySqlClient.CommandResult.ReadNextResult(Boolean isFirst)
at MySql.Data.MySqlClient.CommandResult..ctor(Driver d, Boolean isBinary)
at MySql.Data.MySqlClient.NativeDriver.SendQuery(Byte[] bytes, Int32 length, Boolean consume)
at MySql.Data.MySqlClient.MySqlCommand.GetNextResultSet(MySqlDataReader reader)
at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader()
at Books.Form1.tes1t() in C:\Users\Charis\Documents\Visual Studio 2010\Books\Books\Books\Form1.cs:line 175 Exception caught.
The thread 'vshost.RunParkingWindow' (0x1e94) has exited with code 0 (0x0).
The thread '' (0x158c) has exited with code 0 (0x0).
The program '[2508] Books.vshost.exe: Program Trace' has exited with code 0 (0x0).
The program '[2508] Books.vshost.exe: Managed (v4.0.30319)' has exited with code 0 (0x0).
JohnUSA
4-Dec-10 17:44pm
View
Yes. Still the same problem.
MySql.Data.MySqlClient.MySqlException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[BooksTable] WHERE [author] ='George Elliot' AND [ISBN] ='1234'' at line 1
and at Books.Form1.tes1t() in C:\Users\Charis\Documents\Visual Studio 2010\Projects\Books\Books\Form1.cs:line 173 Exception caught.
Line 173: Reader = command.ExecuteReader();
JohnUSA
4-Dec-10 17:32pm
View
Deleted
The type i had was VARCHAR, tried know TEXT but still can't see anything! What can be the mistake here ?=p everything seems well!
JohnUSA
4-Dec-10 17:31pm
View
The type i had was VARCHAR, tried know TEXT but still can't see anything!
What can be the mistake here ?=p everything seems well
JohnUSA
4-Dec-10 17:04pm
View
Deleted
Sorry,
sql "SELECT * FROM BooksTable WHERE author='George Elliot' AND ISBN='1234'" string
JohnUSA
4-Dec-10 16:51pm
View
sql null string
JohnUSA
4-Dec-10 16:27pm
View
Deleted
When i click button5 and use Console.WriteLine(author); i get "George Elliot" and Console.WriteLine(ISBN) outputs "1234"
JohnUSA
4-Dec-10 16:07pm
View
Deleted
public void tes1t()
{
string MyConString = "SERVER=localhost;" + "DATABASE=books;" + "UID=root;" + "PASSWORD=1234;";
MySqlConnection connection = new MySqlConnection(MyConString);
MySqlCommand command = connection.CreateCommand();
MySqlDataReader Reader;
try
{
connection.Open();
string sql = "SELECT * FROM BooksTable WHERE author='" + author+ "' AND ISBN='" + ISBN + "'";
command.CommandText = sql;
Reader = command.ExecuteReader();
while (Reader.Read())
{
string thisrow = "";
for (int i = 0; i < Reader.FieldCount; i++)
thisrow += Reader.GetValue(i).ToString() + ",";
listBox2.Items.Add(thisrow);
}
connection.Close();
}
catch (Exception e)
{
Console.WriteLine("{0} Exception caught.", e);
}
}
private void button5_Click(object sender, EventArgs e)
{
author= comboBox1.SelectedItem.ToString();
ISBN= comboBox2.SelectedItem.ToString();
tes1t();
}
JohnUSA
4-Dec-10 15:32pm
View
Deleted
It doesn't work without the ') either.
The error that i get is MySql.Data.MySqlClient.MySqlException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'author=1' at line 1.
DBMS ?
JohnUSA
28-Nov-10 19:55pm
View
What information ? Can you point me at the exact link please?
JohnUSA
28-Nov-10 18:32pm
View
What do you mean if the address is valid ? I want when i type New York in the text box and the press the Search button my map to be located on New York.
JohnUSA
24-Nov-10 19:12pm
View
Deleted
Reason for my vote of 5
Excellent! Great help for me!
JohnUSA
24-Nov-10 18:31pm
View
Deleted
How can i pass a JavaScript variable in C# using a button in html?
<input type="button" value="Pass variable to C#" önClick="What is needed??" />
JohnUSA
24-Nov-10 18:29pm
View
Just saw and used your trick. Thanks for this. A million thanks!
JohnUSA
24-Nov-10 17:49pm
View
Deleted
Code is working properly! Thanks for your help aspdotnetdev. Excellent turorial. [Long question removed by AspDotNetDev]
JohnUSA
22-Nov-10 21:31pm
View
I am very confused and i don't think i can't fix this error. I tried what you have told me. My new code is:
public partial class Form1 : Form {
[ComVisible(true)]
public class ScriptManager {
Form mForm;
public ScriptManager() {
}
public void MethodToCallFromScript() {
}
}
public void DoSomething()
{
MessageBox.Show("It works!");
//Will be used for calculations once x and y are retrieved from JavaScript MessageBox.Show("It works!");
}
public Form1()
{
InitializeComponent();
this.webBrowser1.Navigate(@"C:\Users\Charis\Documents\Visual Studio 2010\Projects\FlightScheduler\FlightScheduler\index.html");
webBrowser1.ObjectForScripting = new ScriptManager();
}
I am stuck with it. Can you please show me the way with this code fixed? This would be very helpful for me. As you have seen i am stuck on it :( Thanks again
JohnUSA
22-Nov-10 20:06pm
View
Million thanks for you help once again. I did followed your instruction and came up with this:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace FlightScheduler
{
[ComVisible(true)]
public partial class Form1 : Form
{
public class ScriptManager {
Form mForm;
public ScriptManager(Form form){
mForm = form;
}
public void MethodToCallFromScript() {
}
}
public Form1()
{
InitializeComponent();
this.webBrowser1.Navigate(@"C:\Users\Charis\Documents\Visual Studio 2010\Projects\FlightScheduler\FlightScheduler\index.html");
webBrowser1.ObjectForScripting = new ScriptManager(this);
}
public void DoSomething(){
//Will be used for calculations once x and y are retrieved from JavaScript
MessageBox.Show("It works!");
}
I am on right track now ? Thanks again!!
JohnUSA
22-Nov-10 18:23pm
View
I have give one more try with my code and i came up with something like this:
public class ScriptManager
{
Form1 mForm;
}
public Form1()
{
InitializeComponent();
this.webBrowser1.Navigate(@"C:\Users\Charis\Documents\Visual Studio 2010\Projects\FlightScheduler\FlightScheduler\index.html");
webBrowser1.ObjectForScripting = new ScriptManager();
}
public void DoSomething(){
//Will be used for calculations once x and y are retrieved from JavaScript
}
public void MethodToCallFromScript() {
mForm.DoSomething();
}
I get only one error which is: The name 'mForm' does not exist in the current context. I am not sure what i have done so far and what i have to change.
JohnUSA
22-Nov-10 17:21pm
View
You mean?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace FlightScheduler
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.webBrowser1.Navigate(@"C:\Users\Charis\Documents\Visual Studio 2010\Projects\FlightScheduler\FlightScheduler\index.html");
}
public void DoSomething(){
}
public void MethodToCallFromScript() {
Form1.DoSomething();
}
private void button1_Click(object sender, EventArgs e)
{
DateTime obj = new DateTime();
String travellingDate;
obj = monthCalendar1.SelectionStart;
travellingDate = obj.ToString();
label3.Text = travellingDate.Substring(0, 10);
}
private void button2_Click(object sender, EventArgs e)
{
DateTime obj1 = new DateTime();
String returingDate;
obj1 = monthCalendar2.SelectionStart;
returingDate = obj1.ToString();
label4.Text = returingDate.Substring(0, 10);
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
JohnUSA
22-Nov-10 14:58pm
View
No i haven't managed to fix the code. My C# Code looks like this:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace FlightScheduler
{
public class ScriptManager {
Form mForm;
public ScriptManager(Form form) {
mForm= form;
public void MethodToCallFromScript() {
mForm.DoSomething()
}
}
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.webBrowser1.Navigate(@"C:\Users\John\Documents\Visual Studio 2010\Projects\FlightScheduler\FlightScheduler\index.html");
Webbrowser mBrowserCtrl = new Webbrowser();
mBrowserCtrl.ObjectForScripting = new ScriptManager(this);
}
private void button1_Click(object sender, EventArgs e)
{
DateTime obj = new DateTime();
String travellingDate;
obj = monthCalendar1.SelectionStart;
travellingDate = obj.ToString();
label3.Text = travellingDate.Substring(0, 10);
}
private void button2_Click(object sender, EventArgs e)
{
DateTime obj1 = new DateTime();
String returingDate;
obj1 = monthCalendar2.SelectionStart;
returingDate = obj1.ToString();
label4.Text = returingDate.Substring(0, 10);
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
What are my mistakes on it ? What should i correct?
JohnUSA
22-Nov-10 14:17pm
View
Hello again, i am now trying to pass the variable from JavaScript to C# but i haven't managed it yet. Do i have to do something to "Connect" the JavaScript to the project code? Whatever i have tried i wasn't able to pass the variable which contains x and y retrieved from the mouse click.
JohnUSA
17-Nov-10 11:48am
View
Deleted
Sorry for my late reply but i am very busy. I will give a try to your suggestions and let you know as soon as possible. Your help is realy appreciated! Thanks
JohnUSA
15-Nov-10 20:35pm
View
My application is a Visual C# Windows Form Application. Yes, Google Maps are hosted into a WebBrowser control in a Windows Forms application. WebBrowser navigates to my page (index.html). I am using Appserv to host this page on my localhost. This page is given above in the JavaScript code on the first part of my question.
public Form1()
{
InitializeComponent();
webBrowser1.Navigate("http://localhost/index.html");
}
Thanks for you help once again.
JohnUSA
15-Nov-10 19:48pm
View
Yeah, i did read the article you gave to me but this is not what i want to do. I don't want the variable to be passed from JavaScript to C# with a button click. I want all of the to be stored in an array or something (the X and Y coordinates, each time i click the mouse) and then transfered to C# so i can use them for calculations. I need to say that my C# application is a Windows Form Application not a page.
JohnUSA
15-Nov-10 17:29pm
View
As you can see i am new in C# and JavaScript that's why i have all this "stupid" questions, but document.write(latidute); is just used to check if x and y are taken with the mouse click. I have managed to see that the click works. Now the difficult part for me is to pass the variable to C#. Whatever i've tried didn't worked. I don't know what i should do now, what files to create and how to move on. I am stuck on it :(
JohnUSA
15-Nov-10 17:04pm
View
Haven't managed anything!
JohnUSA
15-Nov-10 15:26pm
View
The best thing on what i need to do is store x and y in table or something and then directly post them to C#. I think that i need a for loop when adding markers using function addMarker(location) { that will store all of the x's and y's and then passed to C#. Is there a way to add some code in my function addMarker to do this things ? i tried with:
var i=0;
for (i=0;i<=markersArray.Length();i++)
{
document.write(latidute);
}
but it doesn't work. any ideas?
JohnUSA
14-Nov-10 20:37pm
View
Since i haven't managed to make it work i haven't updated the code. The thing that i want to do now is by using the function addMarker(location) to get all of the x and y each time the mouse is clicked in the map and then pass all of the variables to C# using an array or something else. So i have to create a new ASP.net page and include the code you provided above ? The code that has to be added in C# is protected void myButton_Click(object sender, EventArgs e)
{
myLabel.Text = "The Javascript told me: " + myHiddenData.Value;
} ?
Thanks for your help.
JohnUSA
14-Nov-10 11:49am
View
First of all sorry for my mistake replying as an answer. I am new here :) About the code, all of this code should be placed in my JavaScript file or i have to add some code in C# application ? I haven't managed to pass variables yet because i get an error on myHiddenData which C# can't recognise. What i've done is that i added this code on my JavaScript file below <div align="center" style="vertical-align:middle;"></div>line and above </body>. Thanks for your help once again.
Show More