469,613 Members | 1,927 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,613 developers. It's quick & easy.

maxdb

i am not able to insert, update or delete to table in maxdb. I am using sql queries for these operations. but i am able to select the already installed values in the table.

My code for select is:

public class Test
{
public static void Main(string[] args)
{
string connectionString =
"Server=192.168.1.78;" +
"Database=maxdb1;" +
"User ID=dbadmin;" +
"Password=nichi;";

MaxDBConnection dbcon = new MaxDBConnection(connectionString);
dbcon.Open();
MaxDBCommand dbcmd = new MaxDBCommand();

string sql = "select * from TEST";
dbcmd.CommandText = sql;
dbcmd.Connection = dbcon;
MaxDBDataReader reader = dbcmd.ExecuteReader();
while (reader.Read())
{
string ID = reader["ID"].ToString();
string NAME = (string)reader["NAME"];
string PRICE = reader["PRICE"].ToString();
Console.WriteLine(ID + " " + NAME + " " + PRICE);
}
reader.Close();
reader = null;
dbcmd.Cancel();
dbcmd = null;
dbcon.Close();
dbcon = null;
Console.ReadKey();
}
}

and that for insert, update and delete is:
using System;
using System.Data;
using MaxDB.Data;
using System.Data.SqlClient;

public class Test
{
public static void Main(string[] args)
{
string connectionString =
"Server=192.168.1.78;" +
"Database=maxdb1;" +
"User ID=dbadmin;" +
"Password=nichi;";

MaxDBConnection dbcon = new MaxDBConnection(connectionString);
dbcon.Open();
MaxDBCommand cmd = new MaxDBCommand();

string sql = "insert into TEST(ID,NAME,PRICE) values(5,'sandy',500)";

//string sql = "delete from TEST where ID = 2";

//string sql = "update TEST set NAME = 'sandy' where NAME = 'deepu'";

dbcmd.CommandText = sql;
dbcmd.Connection = dbcon;
dbcmd.ExecuteNonQuery();
dbcmd.Cancel();
dbcmd = null;
dbcon.Close();
dbcon = null;
Console.ReadKey();
}
}

if any body knows the solution please help me.
Jan 23 '08 #1
0 904

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by dan | last post: by
reply views Thread by Danny | last post: by
reply views Thread by Niranjan | last post: by
1 post views Thread by Steve Malley | last post: by
reply views Thread by Matthias M. | last post: by
reply views Thread by Buck Turgidson | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.