Quantcast
Channel: Oracle, MySQL, Sybase, Informix and other databases
Viewing all 1350 articles
Browse latest View live

mysql entity framework 6

$
0
0

Hi Folks,

I am trying to learn mvc with mysql entity framework 6 code first. I am using VS 2013.

I am really a begginer in this matter.

There are many samples and tutorials around and I have tried some without success.

Can someone recomend a good one for start?

TIA

Moises Durovni


How to convert Student name to student Id

$
0
0

Hi,

I am using visual studio 2010 .I have created web application using Asp.net C# .I need to Import Excel Data into Sqltable called assessment Table. Assessment Table has Following columns 

ID Date BestPlusScore  BestLitScore  BestPlusLevel  BestLitLevel  StudentId

My Excel Has following Columns :

DateBestPlusScoreBestLitScoreBestPlusLevelBestLitLevelStudent Name
8/12/2014880Agaiby Esam
3/29/20142040Amien Mervaf

Instead of studentName  need to convert StudentId from student table .StudentId should be saved in Assessment table.

Can Any one tell me how to convert studentname as student id ? Please Reply as soon as possible :) 

Remove/ Surpress Excel 2007 Extension Warning On Opening Excel Workbook from a Web Site

$
0
0

I added the correct MIME but still getting the warning. 

Response.AppendHeader("content-disposition", "attachment;filename=ExportedExcel.xls");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.ms-excel";

Is there anymore things I need to do pro grammatically to suppress this? 

Thank You

two autoincrement column in 1 table in Mysql db

$
0
0

he guys

is this possible to have 2 autoincrement column in 1 table.

if not then what is the alternative solution???

Using Oracle database in Asp.net

$
0
0

Hello All,

I am an asp.net developer and uses MSSQL as the backend database. Recently I have been told to spoil data from an Oracle database in one of my Applications and dont have any idea of Oracle. Can anyone help me on how to go about this from the connectionstring and what to do.

Thanks in advance

Single quote problem

$
0
0
  Dim ExcelConnection As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source='" & FileSource & "'; Extended Properties=""Excel 12.0 Xml; HDR=Yes""")

        Try
                xlsConn = ExcelConnection.ConnectionString

                Using connection As New OleDbConnection(xlsConn)
                    connection.Open() : ExcelConnection.Open()
                    xlscmd = "SELECT [ME],[Talk Time] FROM [TALK TIME$]"

                    Dim command As New OleDbCommand(xlscmd, connection)

                    Using dr As OleDbDataReader = command.ExecuteReader()

                        ' Bulk Copy to SQL Server
                        Dim sqlConnectionString As String
                            sqlConnectionString = "Data Source=" & MyFunc.SqlConn.DataSource & ";Initial Catalog=" & MyFunc.SqlConn.Database & ";Persist Security Info=True;User ID=sa;Password="

                        Using bulkCopy As New SqlBulkCopy(sqlConnectionString)
                            bulkCopy.DestinationTableName = dbTable
                            bulkCopy.WriteToServer(dr)
                        End Using
                    End Using
                End Using
           
        Catch ex As Exception

        End Try : Return dTable

When I import excel to database table, I found if the cells contains single quote the row will skip to insert into table. I have 1 million data want to insert to the table, so I cant read line by line. Does any one how to solve this problem? My database table structure as below:

[ME] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[TalkTime] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL

mysql ef6 with mvc code first: how to implement membership

$
0
0

Hi folks,

I am starting with MVC 5 (Visual Studio 2013) code first with MySql EF 6.

How do I to implement membership in this cenario?

TIA

Moisés Durovni

ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

$
0
0

hi guys, i have installed MySQL ODBC Driver 3.51 & 5.1 in my pc.

I got the following error if my connection as below:

Dim ConnStr As String = "DRIVER={MySQL ODBC 5.1 Driver};SERVER=localhost;DATABASE=db_testing;UID=user_testing;PASSWORD=12345;OPTION=3;"

ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

* but it's working fine if i change ODBC 5.1 Driver to ODBC 3.51

Please advice. TQ


OleDB duplicating records

$
0
0

Forgive me if this is in the wrong place but I figure I would ask here anyway.  I am using OleDB to read records from Excel.  The crazy thing is it was working properly for the longest.  Now all of a sudden, it takes my records and duplicates them.  To rule out code related issues, I tried a test on an excel with only one record.  That one was fine.  So I figured after my reboot the problem was resolved. It is not.  I simply do not get what the problem is because it does not always do this.  It is at random.

Oracle Error

$
0
0

Please I am trying to connect to an oracle database using vs 2013. I have installed Oracle client but when i run my windows forms app below is the error I get. Can someone please help me.

Attempt to load Oracle client libraries threw BadImageFormatException.  This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed.    at System.Data.OracleClient.OCI.DetermineClientVersion()
   at System.Data.OracleClient.OracleInternalConnection.OpenOnLocalTransaction(String userName, String password, String serverName, Boolean integratedSecurity, Boolean unicode, Boolean omitOracleConnectionName)
   at System.Data.OracleClient.OracleInternalConnection..ctor(OracleConnectionString connectionOptions)
   at System.Data.OracleClient.OracleConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
   at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
   at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
   at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   at System.Data.OracleClient.OracleConnection.Open()
   at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables, Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior behavior)
   at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
   at SaveImage.Form1.button2_Click(Object sender, EventArgs e) in e:\ProjectsTestLab\SaveImageProject\SaveImage\Form1.cs:line 75

Thanks in Advance

How to insert StudentID automatically

$
0
0

Hi ,

 i am using vs2010 .i have created web application using Asp.net c#. I am trying to import excel data in to Sql Table called assessment. Every thing imported fine except studentID column. 

My Assessment table has following columns :

,[Date]
,[BestPlusScore]
,[BestLitScore]
,[BestPlusLevel]
,[BestLitLevel]
,[StudentName]
,[StudentID]

My Excel Has following Columns:

DateBestPlusScoreBestLitScoreBestPlusLevelBestLitLevelStudent Name
8/12/2014880Esam Agaiby

 I need to insert StudentID to assessment table  based on StudentName in  Student Table .

My Student table contains following columns:

[ID]
,[TimeSubmitted]
,[SocialSecurityNumber]
,[EnrollmentDate]
,[FirstName]
,[LastName]

Example:

my excel has StudentName = 'Esam Agaiby'

in Student Table Student_ID=258 for that student name

this StudentId 258 should be insert  into Assessmet table StudentID column

Please help me to solve this problem as  soon as possible :)

SQLite question

$
0
0

We have built a project that runs a SQLite db for the backend stuff. Something we noticed while finishing up the project was issues with Boolean values.

In one table we have 1 column that is set to Boolean as the type, our inserts are working and you can see when a record is inserted that the appropriate data is being inserted and stored. But when viewing the information on the page its always showing false. Now by accident we found out that if we go into the db and simply set and reset the Boolean value, when we revisit the page it shows correct.

So even though our inserts are working, there is a manual step to have it reflect correctly.

Can anyone offer suggestions on how to resolve this or things to try or check to see if we can fix this..

Searching multiple key words in the same field

$
0
0

Hi,

I am trying to build an sql command that selects multiple key words from one field in an Access Database then orders the results by the date they were added

currently my sql statement is as follows;

SelectCommand="SELECT [ID], [PartNo], [Description], [Date] FROM [StockItems] WHERE (([Category] = &quot;TVs&quot; AND &quot;SoundEquipment&quot;) AND ([ShowOnSite] = true)) ORDER BY [Date] DESC"></asp:SqlDataSource>

However currently the command is returning the first category listed (in the case of the example TVs are returned first, if i move Sound equipment to be the first category listed then the sound equipment results are listed first), I need it so that the results are mixed based on the date which they were added.

How to fix this?

Thanks 

Web Service - Need to add transactions

$
0
0

I have a webservice that has one main function.  This function makes several insert/update/deletes as it process.

Each of those insert/update/deletes are in there on function in their respective class's.  

In each of those functions I

  1. Open the connection.
  2. Excecute the database action
  3. Dispose and close the connection.

I have been asked to make this all transaction based, so that after it performs all say 5 inserts/updates/deletes (depending on what was sent to the service) Then I can commit or rollback at the very end of the main function.

I have found examples on how to do it on each Insert/update/delete.  The goal is to make sure they are all successful and then commit, or if any fail, rollback.

VS 2013 and mySQL problems

$
0
0

I'm experienced in building web sites using VS 2013 but never used mySQL until now.  I can't seem to connect to the mySql database I created.  Here is my code:

string MyConString = "SERVER=localhost;" +
"DATABASE=XXXXXDB;" +
"UID=bobh;" +
"PASSWORD=ppppppppp;";
MySqlConnection connection = new MySqlConnection(MyConString);
MySqlCommand command = connection.CreateCommand();
MySqlDataReader Reader;
command.CommandText = "select * from Products";
connection.Open();
Reader = command.ExecuteReader();
while (Reader.Read())
{
string thisrow = "";
for (int i = 0; i < Reader.FieldCount; i++)
thisrow += Reader.GetValue(i).ToString() + ",";
//gvProducts.Rows.Add(thisrow);
}
connection.Close();

On the connection.Open() line I get this error:

[MySqlException (0x80004005): Authentication to host 'localhost' for user 'bobh' using method 'mysql_native_password' failed with message: Access denied for user 'bobh'@'localhost' (using password: YES)]
   My

What am I doing wrong?


Inner Join with Same Table

$
0
0

Dear All,

i have a company table at below.


comid   companyname parentcompany maincom
------- ----------- --------------
1          test       0             1
2          testxx     1             0



so here the second record i have parent company = 1 meaning company test as parent for textxx , if a company has parentcompany as 0 means tat has no parent company.

so in this i need have a result to display in grid is


companyname             parentcompany
test                       no
testxx                     test



i tired with inner join , but it is only select the second record as it's skip the first record due inner join with comid .

please advice.

Looking for your valuable reply!!!

Regards,

Muthu

How Do I Ensure Good Quality Images

$
0
0
good day guys and girls, i insert images into mysql database using the following blocks of code

protected void ad3upload_Click(object sender, EventArgs e)
        {
            if (FileUpload6.HasFile)
            {
                string fileName = FileUpload6.FileName;
                string path = fileName;
                TextBox13.Text = fileName;
                FileUpload6.SaveAs(Server.MapPath(path));
                pass3img.ImageUrl = path;
 
                //this gets admin1passport
                Stream fs3 = FileUpload6.PostedFile.InputStream;
                BinaryReader br3 = new BinaryReader(fs3);
                Byte[] bytes3 = br3.ReadBytes((Int32)fs3.Length);
 
                try
                {
                    MySqlConnection conn = new MySqlConnection(connection);
                    MySqlCommand ins = new MySqlCommand("update tables.admintable set Passport = @img where Name = '" + newname.Text + "'", conn);
                    MySqlDataReader read;
                    conn.Open();
                    ins.Parameters.Add("@img", MySqlDbType.Binary).Value = bytes3;
                    read = ins.ExecuteReader();
                    conn.Close();
                    Label84.ForeColor = System.Drawing.Color.Green;
                    Label84.Text = "Successful Upload";
                }
                catch (MySqlException)
                {
                    Label84.ForeColor = System.Drawing.Color.Red;
                    Label84.Text = "Failed Upload, Please Try Agin";
                }
                catch (Exception)
                {
                    Label84.ForeColor = System.Drawing.Color.Red;
                    Label84.Text = "Failed Upload, Please Try Agin";
                }
            }
        }
it succesfully uploads buy when i recall the image from the database through these set of codes
protected void adminListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                MySqlConnection conn = new MySqlConnection(connection);
                MySqlCommand select = new MySqlCommand("select Passport from tables.admintable where Name = '" + Label33.Text + "'", conn);
                MySqlDataReader read;
                conn.Open();
                read = select.ExecuteReader();
                while (read.Read())
                {
                    byte[] passportImage1 = (byte[])(read["Passport"]);
                    if (adminListBox.SelectedIndex.Equals(0))
                    {
                        if (passportImage1 == null)
                        {
                            adminImage.ImageUrl = null;
                        }
                        else
                        {
                            MemoryStream ms = new MemoryStream(passportImage1); // this holds the image gotten from the database
                            string base64string = Convert.ToBase64String(passportImage1, 0, passportImage1.Length);
                            adminImage.ImageUrl = "data:image/png;base64," + base64string;
                        }
                    }
                }
                read.Close();
                conn.Close();
            catch (MySqlException)
            {
                Label84.ForeColor = System.Drawing.Color.Red;
                Label84.Text = "Failed Upload, Please Try Agin";
            }
            catch (Exception)
            {
                Label84.ForeColor = System.Drawing.Color.Red;
                Label84.Text = "Failed Upload, Please Try Agin";
            }
            }
        }
this gets the image quite alright but it looks like its a cracked image on display, like its corrupted.
i want it to show clearly. please what am i missing?

mysql database connection

$
0
0

i have download sqlyog for my database mysql manange tool. when i create a new localhost connection, it prompts error

error  number 2003: can't connect mysql server on localhost(0)

how to fix it.

Tel number 8613564026562 becomes 8.61356E+12

$
0
0

As title. When I retrieve my telephone number and export it to excel. It became a weird "formulated" number.

Why is this happening? 

How can I fix this? This is very strange to me 

check if value exist into database (best way)

$
0
0

how to prevent duplicate CustName insert into database, can i use Linq method to filter but do not has data table? has any best way to do ?

 protected void btnSave_Click(object sender, EventArgs e)
        {
            using (MySqlConnection connection = new MySqlConnection(ConfigurationManager.ConnectionStrings["conString"].ToString()))
            {
                try
                {
                    connection.Open();

                    MySqlCommand cmdInsert = new MySqlCommand("Insert Into Customer(CustName,CustPhone,CustEmail,CustAddress) VALUES (@CustName, @CustPhone, @CustEmail, @CustAddress)", connection);

                    cmdInsert.Parameters.AddWithValue("@CustName", txtName.Text);
                    cmdInsert.Parameters.AddWithValue("@CustPhone", txtPhoneNo.Text);
                    cmdInsert.Parameters.AddWithValue("@CustEmail", txtEmail.Text);
                    cmdInsert.Parameters.AddWithValue("@CustAddress", txtAddress.Text);
                    int check = cmdInsert.ExecuteNonQuery();
                    if (check > 0)
                        Clear();
                    else
                        ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "Connection Fail", "alert('Fail to Insert !!! Please Try Again')", true);
                }
                catch (MySqlException)
                {
                    throw;
                }
                finally
                { 
                    connection.Close();
                }
            }
        }

Viewing all 1350 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>