Conexión a SQL CE - URGENTE

14/06/2004 - 08:35 por Alexander Díaz M. | Informe spam
Hola Grupo,

Después de mucho luchar he logrado crear una base de datos en mi dispositivo
pocket, el problema es que no puedo conectarme desde mi aplicación vb.net a
el servidor SQL CE (el de la pocket), empezando porque no se cual es el
nombre del servidor ni donde configuro el usuario. AUXILIO

El código que uso para la conexión es el siguiente:

Public adoDatos As SqlServerCe.SqlCeConnection
adoDatos.ConnectionString = "server=alexander;database=fuper;" + _

"user id=admin;password=fuper;"

adoDatos.Open()

como mencioné antes no tengo ni idea cual es el nombre del servidor ni donde
configuro (en sql ce) el nombre del usuario,

De antemano y como siempre Gracias



Alexander

Preguntas similare

Leer las respuestas

#1 José Miguel Torres
14/06/2004 - 10:16 | Informe spam
te paso un paste del books online, mira el punto 6
To create a new SQL Server CE database

1.. Start Visual Studio .NET and open a new project.
2.. Create references to the namespaces you are using:
using System;
using System.IO;
using System.Text;
using System.Data;
using System.Data.SqlServerCe;
using System.Collections;
using System.Windows.Forms;
using System.Data.Common;
3.. Create the WalkThrough class:
public class WalkThrough
{
static void Main()
{
SqlCeConnection conn = null;

try
{
4.. Verify that a database with the name you plan to use does not already
exist:
if (File.Exists ("Test.sdf") )
File.Delete ("Test.sdf");
5.. Create an empty database, by using the SqlCeEngine object:
SqlCeEngine engine = new SqlCeEngine ("Data Source = Test.sdf");
engine.CreateDatabase ();
6.. Connect to the new database, by using the SqlCeConnection object:
conn = new SqlCeConnection ("Data Source = Test.sdf");
conn.Open();
To create a new table

1.. Create an instance of the command class, by using the SqlCeCommand
object:
SqlCeCommand cmd = conn.CreateCommand();
2.. Run a command to create the table:
cmd.CommandText = "CREATE TABLE TestTbl(col1 int PRIMARY KEY, col2 ntext,
col3 money)";
cmd.ExecuteNonQuery();
To populate a new table with data

1.. Run a command to insert a row of data:
cmd.CommandText = "INSERT INTO TestTbl(col1, col2, col3) VALUES (0, 'abc',
15.66)";
cmd.ExecuteNonQuery();
2.. Using SqlCeParameter, create a command using parameters to insert data
to the table multiple times:
cmd.CommandText = "INSERT INTO TestTbl(col1, col2, col3) VALUES (?, ?, ?)";

cmd.Parameters.Add(new SqlCeParameter("p1", SqlDbType.Int));
cmd.Parameters.Add(new SqlCeParameter("p2", SqlDbType.NText));
cmd.Parameters.Add(new SqlCeParameter("p3", SqlDbType.Money));

cmd.Parameters["p2"].Size = 50;

cmd.Prepare();
3.. Execute the parameterized command to insert data to the table:
cmd.Parameters["p1"].value = 1;
cmd.Parameters["p2"].value = "abc";
cmd.Parameters["p3"].value = 15.66;
cmd.ExecuteNonQuery();
4.. Clear the parameter, and check the data you inserted into the table:
cmd.Parameters.Clear();
//Set the command text to a SELECT query.
//
cmd.CommandText = "SELECT * FROM TestTbl";
Reading SQL Server CE Database Data
The following example shows how to read data in an existing SQL Server CE
database by using the SqlCeDataReader class:

SqlCeDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
MessageBox.Show("col1 = " + rdr.GetInt32(0) +
"col2 = " + rdr.GetString(1) +
"col3 = " + rdr.GetSqlMoney(2));
For the complete code that you can copy, paste, and run in a Visual Studio
.NET project, see "Walkthrough Sample" earlier in this topic.



Saludos


José Miguel Torres
jtorres_diaz~~ARROBA~~terra.es

"Alexander Díaz M." escribió en el mensaje
news:#
Hola Grupo,

Después de mucho luchar he logrado crear una base de datos en mi


dispositivo
pocket, el problema es que no puedo conectarme desde mi aplicación vb.net


a
el servidor SQL CE (el de la pocket), empezando porque no se cual es el
nombre del servidor ni donde configuro el usuario. AUXILIO

El código que uso para la conexión es el siguiente:

Public adoDatos As SqlServerCe.SqlCeConnection
adoDatos.ConnectionString = "server=alexander;database=fuper;" + _

"user id=admin;password=fuper;"

adoDatos.Open()

como mencioné antes no tengo ni idea cual es el nombre del servidor ni


donde
configuro (en sql ce) el nombre del usuario,

De antemano y como siempre Gracias



Alexander


Respuesta Responder a este mensaje
#2 Alexander Díaz M.
14/06/2004 - 18:57 | Informe spam
Gracias Miguel, voy a probar.


"José Miguel Torres" <jtorres_diaz~~ARROBA~~terra.es> escribió en el mensaje
news:%23sJG%
te paso un paste del books online, mira el punto 6
To create a new SQL Server CE database

1.. Start Visual Studio .NET and open a new project.
2.. Create references to the namespaces you are using:
using System;
using System.IO;
using System.Text;
using System.Data;
using System.Data.SqlServerCe;
using System.Collections;
using System.Windows.Forms;
using System.Data.Common;
3.. Create the WalkThrough class:
public class WalkThrough
{
static void Main()
{
SqlCeConnection conn = null;

try
{
4.. Verify that a database with the name you plan to use does not already
exist:
if (File.Exists ("Test.sdf") )
File.Delete ("Test.sdf");
5.. Create an empty database, by using the SqlCeEngine object:
SqlCeEngine engine = new SqlCeEngine ("Data Source Test.sdf");
engine.CreateDatabase ();
6.. Connect to the new database, by using the SqlCeConnection object:
conn = new SqlCeConnection ("Data Source = Test.sdf");
conn.Open();
To create a new table

1.. Create an instance of the command class, by using the SqlCeCommand
object:
SqlCeCommand cmd = conn.CreateCommand();
2.. Run a command to create the table:
cmd.CommandText = "CREATE TABLE TestTbl(col1 int PRIMARY KEY, col2 ntext,
col3 money)";
cmd.ExecuteNonQuery();
To populate a new table with data

1.. Run a command to insert a row of data:
cmd.CommandText = "INSERT INTO TestTbl(col1, col2, col3) VALUES (0,


'abc',
15.66)";
cmd.ExecuteNonQuery();
2.. Using SqlCeParameter, create a command using parameters to insert data
to the table multiple times:
cmd.CommandText = "INSERT INTO TestTbl(col1, col2, col3) VALUES (?, ?,


?)";

cmd.Parameters.Add(new SqlCeParameter("p1", SqlDbType.Int));
cmd.Parameters.Add(new SqlCeParameter("p2", SqlDbType.NText));
cmd.Parameters.Add(new SqlCeParameter("p3", SqlDbType.Money));

cmd.Parameters["p2"].Size = 50;

cmd.Prepare();
3.. Execute the parameterized command to insert data to the table:
cmd.Parameters["p1"].value = 1;
cmd.Parameters["p2"].value = "abc";
cmd.Parameters["p3"].value = 15.66;
cmd.ExecuteNonQuery();
4.. Clear the parameter, and check the data you inserted into the table:
cmd.Parameters.Clear();
//Set the command text to a SELECT query.
//
cmd.CommandText = "SELECT * FROM TestTbl";
Reading SQL Server CE Database Data
The following example shows how to read data in an existing SQL Server CE
database by using the SqlCeDataReader class:

SqlCeDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
MessageBox.Show("col1 = " + rdr.GetInt32(0) +
"col2 = " + rdr.GetString(1) +
"col3 = " + rdr.GetSqlMoney(2));
For the complete code that you can copy, paste, and run in a Visual Studio
.NET project, see "Walkthrough Sample" earlier in this topic.



Saludos


José Miguel Torres
jtorres_diaz~~ARROBA~~terra.es

"Alexander Díaz M." escribió en el mensaje
news:#
> Hola Grupo,
>
> Después de mucho luchar he logrado crear una base de datos en mi
dispositivo
> pocket, el problema es que no puedo conectarme desde mi aplicación


vb.net
a
> el servidor SQL CE (el de la pocket), empezando porque no se cual es el
> nombre del servidor ni donde configuro el usuario. AUXILIO
>
> El código que uso para la conexión es el siguiente:
>
> Public adoDatos As SqlServerCe.SqlCeConnection
> adoDatos.ConnectionString = "server=alexander;database=fuper;" + _
>
> "user id=admin;password=fuper;"
>
> adoDatos.Open()
>
> como mencioné antes no tengo ni idea cual es el nombre del servidor ni
donde
> configuro (en sql ce) el nombre del usuario,
>
> De antemano y como siempre Gracias
>
>
>
> Alexander
>
>


email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida